Git: Correct way to change Active Branch in a bare repository?

If you have access to the remote bare repo, this article suggests:

git symbolic-ref HEAD refs/heads/mybranch

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

ref: refs/heads/mybranch

as documented in the git-symbolic-ref


If you don’t have access to the remote repo, see my previous answer.


Remember that a command like git remote set-head:

  • doesn’t change the default branch of the remote repo.
    It only changes a remote tracking branch stored in your local repo as refs/remotes/<name>/HEAD

  • doesn’t change HEAD itself (again, only refs/remotes/<name>/HEAD), hence the need for
    git symbolic-ref.

So git remote set-head is not the answer here.
git symbolic-ref HEAD is, if you have direct access to the remote repo.

Leave a Comment