I want to get how many commits has done until a certain branch created from the Github API.
For example in git cli I'm doing: git log --no-merges --oneline ${branchHash} | wc -l
and I can see the number.
From the Github API there's a limit of 100 so if I have more than 100 commits I can't get them all.
Is there any solution for that case?
On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.
Which Command is used to show limited number of commits? git log -n Command is used to show limited number of commits.
I wrote a little thing to solve this:
Gist "Easy way to calculate commits count from the GitHub API".
It is based on using the compare
URL of the GitHub Commit API, and using the total_commits
field:
compare_url = '{}/repos/{}/{}/compare/{}...{}'.format(base_url, owner, repo, first_commit, sha)
commit_count = commit_req.json()['total_commits'] + 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With