Set Git Default Initial Branch Name

Set Git Default Initial Branch Name

One essential aspect of Git repositories is the default branch, often referred to as the "main" or "master" branch. To promote inclusive language and follow industry trends, many projects are shifting towards using more neutral terms like "main" as the default branch name. This tutorial explains how to set Git default initial branch name.

To set the default branch name globally for all Git repositories, use the following command:

git config --global init.defaultBranch main

This command modifies global Git configuration to ensure that whenever you create a new repository, Git will automatically use "main" as the default branch name instead of the traditional "master".

To ensure that global configuration has been set correctly, use the following command:

git config init.defaultBranch

Leave a Comment

Cancel reply

Your email address will not be published.