Search code examples
gitversion-control

How can I know the master branch name of a repository?


I assume that the name master branch which is the "main" branch that everyone is working in a git repository,is just a convention. Right?
So how can I know what is the "main" branch name in a git repository that has overriden so as not to use the name master?


Solution

  • Yes, master is just a convention. Not every repository has a branch called master. Also git allows you arbitrary work flows. Different projects use different branching strategies. There might be something like a "main branch", but sometimes there is simply no need for it.

    You can always use git branch -m to give a commit a new name and git reset to give a name a new commit.

    Most of the time you can use the name of the branch to get an idea what it includes. Otherwise can use something like gitk to have a look at your commit graph. This might help you to recognize something like a "main branch".