GitHub API: identify branches that contain a given commit

Given the SHA of a specific commit in my repo, I want to identify branches containing commit using the GitHub API .

I know I can do it locally using git directly in various ways, including

 git branch --contains <commit> 

but this is for an integrated page that retrieves data from multiple platforms, so I really need to use the API.

This question had an accepted answer, which said that this was not possible in 2013, but I hope that from now on the API will add something in this direction.

Does anyone know how to get this information without asking for a list of ALL commits in the branches of interest and iterating through them to compare?

+7
github
source share
2 answers

None of the Commit Repository , Git Commit nor Git Links> endpoints provide this data, so I think the API just doesn't.

But the website shows this data, so if you desperately need it, you can try to clear the commit page ( https://github.com/:user/:repo/commit/:sha ) and get commit-branches div.

Finally, the Github support is great, so you should ask them - in the worst case, they say that it is not implemented, but maybe they put it on the TO-DO list.

+2
source share

Could not find s.th. nor did I end up using an unofficial API (I think):

https://github.com/:user/:repo/branch_commits/:commit

You still need to clear the answer, but it is much shorter and faster. If the answer simply contains spaces, there is no branch for this commit.

+2
source share

All Articles