Which is the best way to get the latest commit information from a git repository using GitHub API (Rest API v3).
Can I assume that the object ‘commit’ of the response is the latest commit from branch master?
Or make two calls, one to get the sha by getting the HEAD ref from master and then get the commit information using the sha returned.
It depends on your definition of “last”.
for a given branch (like
GET /repos/:owner/:repo/commits/masteris indeed the last (most recent) commit.
But you can also consider the last push event: that would represent the last and most recent commit done (on any branch), pushed by a user to this repo.
Answered By – VonC