Git config
Default branch
Initialize repos with main
as default branch:
git config --global init.defaultBranch main
Load dynamically git configurations per context with: [includeIf]
It is possible to load git configuration per context with [includeIf…]
I used to split the git repos in my directory tree into several contexts, like
. └── gits ├── general ├── priv │ └── .gitconfig └── work └── .gitconfig
where work are repos I need for work, priv are my personal ones and general neither nor. For work I have different settings than for priv - like user.email, user.name and similar. To anything else not configured explicetely this way the general settings from my global ~/.gitconfig apply. The relevant part of my ~/.gitconfig
is the following:
[includeIf "gitdir:~/gits/priv/"] path = ~/gits/priv/.gitconfig [includeIf "gitdir:~/gits/work/"] path = ~/gits/work/.gitconfig
which causes git to load the configuration in the root of the priv and/or work folder when I work on repositories below those folders.
And from now the settings in the custom .gitconfig files will overrule same settings from the global ~/.gitconfig - and additional settings will extend it.