My goal is to get the tree for the latest SHA in the default branch
GET /repos/:owner/:repo/git/trees/:sha
How do I find the lastest SHA from the default branch?
I know that I can call
GET /repos/:owner/:repo/branches/:branch
But I can't just use "master" for the branch as not all repos use master as the default branch.
How do I find out what the default branch for a repo is?
Unless you specify a different branch, the default branch in a repository is the base branch for new pull requests and code commits. By default, GitHub names the default branch main in any new repository. You can change the default branch for an existing repository.
The default branch name in Git is master .
The default branch name for new repositories is now main . To set a different default: For users, on the https://github.com/settings/repositories page. For organization owners, on the https://github.com/organizations/YOUR-ORGANIZATION/settings/repository-defaults page.
Make a call to /repos/:owner/:repo
and read the default_branch
property value - this is the name of the default branch. See example response here: http://developer.github.com/v3/repos/#get
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