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
teto
February 10, 2024, 10:14pm
2
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";
};
9 Likes
Man, does this really change this frequently? The correct config now is apparently:
programs.git = {
enable = true;
settings = {
user = {
name = "John Doe";
email = "johndoe@example.com";
};
init.defaultBranch = "main";
};
};
or:
programs.git.init.defaultBranch = "main";
Always double check with the NixOs/Git wiki: https://nixos.wiki/wiki/Git
P.S: This post was ranked at the top on Google searches for this topic for me. Better update it.
Wrong wiki, the official one is wiki.nixos.org .
Also, the people here are confusing NixOS (programs.git.config) and home-manager config (programs.git.settings) - the options are named differently.
For something this simple, forget wikis, just use the options search.
https://search.nixos.org/options?channel=25.11&query=programs.git.
https://home-manager-options.extranix.com/?query=git.&release=master
This is definitely wrong and doesn’t correspond to either of NixOS / hm.
2 Likes