Suppose you want the default branch name created by git init
(or tools that shell out to it, like cargo new
) to be something other than master
. In this example, I'll call it develop
.
-
Add the following to your
.gitconfig
:[init] templateDir = ~/.config/git/template/
This tells
git init
to use the files found in~/.config/git/template
to populate the initial.git
directory. You can use whatever path you'd like. -
Create a file in the template directory called
HEAD
, for example~/.config/git/template/HEAD
, with the following contents:ref: refs/heads/develop
Replace
develop
with the default name of your choice.
Very cool. Thanks for sharing!