Set default branch in git bare repository

Sometimes I use a git bare repository without a configured master branch. If you clone a bare repository without a master branch, git will cry all the time that no HEAD is configured on the bare repsitory.

So we have to setup a different default branch on that bare repository. A bare repository in git does not include a checkout. So in order to set the default branch that users will get after they clone, you cannot use git-checkout mybranch.

Instead, if you want the default branch to be something other than master, you need to do this:

git symbolic-ref HEAD refs/heads/mybranch

Which will update the HEAD file in your repository so that it contains:

ref: refs/heads/mybranch
comments powered by Disqus