I have a bare repository that's used as the central store for my project. All the developers do
git clone <repo>
git clone -n
git checkout <otherbranch>
git update-ref HEAD refs/heads/otherbranch
git update-ref --no-deref HEAD refs/heads/otherbranch
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:
as documented in the
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
HEAD itself (again, only
refs/remotes/<name>/HEAD), hence the need for
git remote set-head is not the answer here.
git symbolic-ref HEAD is, if you have direct access to the remote repo.