How do I set a Git remote’s HEAD reference to point to something besides “master”?
My project has a policy not to use a “master” branch (all branches are to have meaningful names). Furthermore, the canonical master repository is only accessible via ssh://, with no shell access (like GitHub or Unfuddle).
My problem is that the remote repository still has a HEAD reference to refs/heads/master, but I need it to point to a different branch. This is causing two problems:
-
When cloning the repo, there this,
warning: remote HEAD refers to nonexistent ref, unable to checkout.
That’s confusing and inconvenient.
-
The web-based code browser depends on HEAD as a basis for browsing the tree. I need HEAD to point to a valid branch, then.
There was almost the same question on GitHub a year ago.
The idea was to rename the master branch:
(a "
git-symbolic-ref HEAD refs/head/published" would not be propagated to the remote repo)This is similar to "How do I delete origin/master in Git".
As said in this thread: (emphasis mine)
(which is all besides the point of your question, I know 😉 )
Maybe the only way would be a "publication for the poor", where you:
But that would involve write access to the server, which is not always possible.
As I explain in "Git: Correct way to change Active Branch in a bare repository?",
git remote set-headwouldn’t change anything on the remote repo.It would only change the remote tracking branch stored locally in your local repo, in
remotes/<name>/HEAD.With Git 2.29 (Q4 2020), "
git remote set-head(man)" that failed still said something that hints the operation went through, which was misleading.See commit 5a07c6c (17 Sep 2020) by Christian Schlack (
cschlack).(Merged by Junio C Hamano —
gitster— in commit 39149df, 22 Sep 2020)