Skip to content

fetch-depth question #1734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
y-nk opened this issue May 17, 2024 · 3 comments
Open

fetch-depth question #1734

y-nk opened this issue May 17, 2024 · 3 comments

Comments

@y-nk
Copy link

y-nk commented May 17, 2024

I've set fetch-depth to ${{ github.event.pull_request.commits }} to avoid fetching my whole repo. The action executes like this:

image

So then i would expect to have 12 commits (11 + the merge commit) in the rev-list, but i get much more than this.

image

not sure why. could somebody tell me if it's normal?

@davhdavh
Copy link

davhdavh commented Jun 6, 2024

The default is to only download the files specifically for the commit you are building, ie fetch-depth:1 is what you want.

@y-nk
Copy link
Author

y-nk commented Jun 8, 2024

i would like to add that i do not use the /merge in ref, so fetch: 1 does not match. i'd like to checkout consistently [github.event.before, ..., github.event.pull_request.head.sha]

@gofr
Copy link

gofr commented Apr 2, 2025

Yes, this is normal.

fetch-depth: 3, for example, means that Git fetches the HEAD commit (depth=1), all its parents (depth=2) and all its grandparents (depth=3).

So with a Git history like this:

a - b --------- e
      \       /
        c - d

that will give you commits e (HEAD), b and d (both of its parents), and a and c (all of their parents). That's 5 commits, not 3 like you might've expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants