skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. Git has multiple levels of config: system, global, local.

    If you want to quickly verify what happens in your local repo justgit config -e --local or git config --list to see

    Otherwise modify the global ~/.gitconfig yourself config and add/update section:

    [init]
      defaultBranch = main
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search