Skip to content
Advertisement

Can’t change git default branch to main on the command line

I’ve read on several sites that you can use git config --global init.defaultBranch main to change the default branch (from master) to main. But it doesn’t work for me. Here it’s from my terminal (my os is ubuntu):

$ git config --list
user.email=*************
user.name=********
credential.helper=store
core.editor=nano

$ git config --global init.defaultBranch main
$ git config --list
user.email=*************
user.name=*************
credential.helper=store
core.editor=nano
init.defaultbranch=main

$ mkdir testrepo
$ cd testrepo
$ git init
Initialized empty Git repository in /home/user/Desktop/testrepo/.git/

$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)

Advertisement

Answer

The option init.defaultBranch was introduced in Git version 2.28. You must be running an older version which does not honor this option.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement