On vscode, using wsl
terminal, I was setting the global the default branch as main
as shown below,
git config --global init.defaultBranch main
Now, inside my project folder, when I do git init
and check git status
the default branch is still master
. What else I need to do to make the default branch as main
?
Even .gitconfig
, contains defaultBranch as main:
cat ~/.gitconfig
[init]
defaultBranch = main
Current git version:
git version2.25.1
2
Answers
I tried to update the git version from
git version2.25.1
to current latest version i.e.,git version 2.41.0
. After this my git configurations are getting correctly detected.From @RickN's comment,
The defaultBranch option was introduced in Git 2.28, so your config file was detected without fault, just with an unsupported configuration option.
Git has multiple levels of config: system, global, local.
If you want to quickly verify what happens in your local repo just
git config -e --local
orgit config --list
to seeOtherwise modify the global
~/.gitconfig
yourself config and add/update section: