Github API: how to view open commits on a specific branch?


I am looking for functionality in the github api, to see if there are still open commits on specific branch.

With open commits, I mean all commits that aren’t yet merged with the default branch.

I tried to use the “list branches” api (, but this doesn’t return any information on commits.

Note: I posted the same question on stackoverflow ( and (


I’m not clear on what you’re trying to determine, but the github API isn’t designed to answer this type of question directly.

You appear to be looking for information about the relationship between two git branches. Your question can be answered directly in git – i.e. you don’t need to utilize any of the GitHub extras (like issues or PRs). GitHub can provide you the same underlying git information. (See the Git Data section of the API.)

My suggestion would be to:

  1. use the git cli to refine exactly what you want (could be git log or git diff output).
  2. determine how to get that answer using low level plumbing commands
  3. determine how to use the API to obtain the same information from GitHub.

Good luck!