Where to configure default git branch name

I have configured the default branch name with:

programs.git.configExtra = ''
[init]
defaultBranch = main
'';

However, every time I recompile my home manager config it gives me this error:

trace: warning: Using programs.git.extraConfig as a string option is
deprecated and will be removed in the future. Please
change to using it as an attribute set instead.

My question is where should I config this?
I know the attributes can be found in the man page, but I do not know which specific attribute to configure.

1 Like

It’s as simple as using

programs.git.configExtra = {
init.defaultBranch = main
}

instead

Thank you. This worked when I put main in double quotes.

programs.git.configExtra = {
  init.defaultBranch = "main";
};
1 Like

The solution didn’t work for me. Turns out configExtra is now extraConfig so this works:

programs.git.extraConfig = {
  init.defaultBranch = "main";
};
1 Like

the solution above no longer works. looks like it’s renamed to just programs.git.config

programs.git.config.init.defaultBranch = "main";

For home-manager users stumbling upon this thread, the correct attribute is called extraConfig. Here’s the config:

programs.git = {
  enable = true;
  
  extraConfig.init.defaultBranch = "main";
};