2

i get all commits of a repo with:

curl  -I -k -u ${api_user}:${api_token} "${api_url}/commits?sha=${api_branch}&per_page=1" | sed -n '/^[Ll]ink:/ s/.*"next".*page=\([0-9]*\).*"last".*/\1/p'

Is there a similar way for git rev-list with the GitHub Rest API and curl?

Thanks in advance!

1
  • I'm a bit confused: are you looking for a git rev-list command that does what your curl does, or are you looking for a curl operation that does what git rev-list does? Commented Aug 24, 2021 at 7:43

1 Answer 1

1

The GitHub API v3 Commits API is the closest:

GET /repos/{owner}/{repo}/commits

It could be the very same you are using, depending on what ${api_url}.
Like git rev-list, it includes a commit reference from which the list starts.
And a path, to only list commits modifying the given <paths>.

It would not, howver, allow more complex commit specification, like git rev-list foo bar ^baz, which lists all the commits which are reachable from foo or bar, but not from baz.

For that, you would need a GraphQL query, using Commit object, like in [those] examples.6

Sign up to request clarification or add additional context in comments.

2 Comments

okay, maybe i can get all commits with curl and extracting the commits who have 2+ parents?
@RomanBürkle Yes: any commit reachable from the starting point will be listed, including commits with two+ parents.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.