Setting default branch name when creating repo with gitignore_template

Today we often set gitignore_template in the body when creating new repos on GitHub through our tooling.

However, the branch name in such cases is set automatically to ‘master’, and we’re looking to evolve that nomenclature.

Is it possible there may be an expansion to this CREATE REPO API as documented at to be able to set the name of the branch while using the gitignore_template to create initial files in the repo?

Otherwise, it’ll take a bit of work for us to use additional API calls to change refs and the default branch at create time; I imagine GitHub is already working on this some.


1 Like

:wave: @jeffwilcox––There’s not an endpoint in the Repositories API that would allow you to specify a default branch when creating a repository from either of these endpoints:

However, there’s an API endpoint for creating a repository using a template. One approach you can take is creating a repository and making it a repository template for other repositories to be created from. If it sets something other than master as the default branch, that’s preserved.

Here’s an example repository template:

Before that endpoint existed, we acknowledge that the process involves a few more steps than what may be desired from a developer experience:

While we can’t speak to upcoming updates for specific API endpoints, would you mind submitting this through our official product feedback form so that our product team can track your request? That’s the best place to share requests like these in consideration for future iterations of GitHub.

Good evening,
Really good initiative I guess, thanks !