Change the default git branch name from master to main

Git create default branch name as main instead of master

master is the default branch that is created when you create a git repo using the git init command, note this is the case if you are using the git version below 2.28. If you are using version 2.28 or above you will see the default branch name as main

You can make use of the git config command to set the global value for init.defaultBranch as main as below,

% git config --global init.defaultBranch main
% mkdir myrepo
% cd myrepo
% git init
Initialized empty Git repository in /myrepo/.git/

(main) % 

The term "master" name should be changed to avoid any unnecessary references to slavery and should use neutral words like main or primary

Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.