A simple way to change the default HEAD is to create a HEAD in the git template dir. First, configure your template dir to ~/Templates/git.git
(or whatever you'd prefer):
$ git config --global init.templateDir '~/Templates/git.git'
$ cp -r /usr/share/git-core/templates ~/Templates/git.git
Then, create the file HEAD
in the template dir:
$ echo 'ref: refs/heads/default' > ~/Templates/git.git/HEAD
And you're good to go! Whenever you run git init
, you'll now get the message:
$ git init
Reinitialized existing Git repository in [...]
For some reason, git decides whether to use this message based on the presence of the HEAD
file in .git
, rather than relying on whether or not .git
had to be created. However, it really doesn't matter what message it shows you. From the git-init man page:
Running git init
in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init
is to pick up newly added templates (or to move the repository to another place if --separate-git-dir
is given).
That is to say, git init
is guaranteed not to overwrite the HEAD
you put in the template, and it won't use the template's HEAD
to overwrite an existing HEAD
either. Since this is explicitly documented, you can rely on it.
Additionally, it also says:
Files and directories in the template directory whose name do not start with a dot will be copied to the $GIT_DIR
after it is created.
Which means you can also rely on the template being copied immediately after the creation of .git
, and not at a later point.
(Of course, this is my personal interpretation of the manual. It's entirely possible that the git developers will disagree.)