Last Updated: February 25, 2016
· allolex

Set the default branch in a Git repository

If you're not using master as your main branch, it's useful to create an affordance for your repository users by setting the default branch to your main branch.

You do this by creating a symbolic reference to the branch head in .git/HEAD. Running git symbolic-ref HEAD refs/heads/main_branch will do the trick.

$ cat .git/HEAD
ref: refs/heads/main_branch