Change a Git remote HEAD to point to something besides master

Viewed 210033

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:

  1. When cloning the repo, there this,

    warning: remote HEAD refers to nonexistent ref, unable to checkout.

    That's confusing and inconvenient.

  2. 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.

12 Answers

Related to the question, I ended up here when searching for:

How do I make a local repo aware of a changed default branch on GitHub

For completeness, adding the answer:

git remote set-head origin -a

The best and straight-forward way to change git remote HEAD is to run

git remote set-head origin DEV

origin is usually the remote name DEV the remote branch name

Related