Default branch for new repo git
By default, when you create a new Git repository, the default branch is named master
. This is because the master
branch is the traditional and most widely used branch name in Git, and it's often used as the main branch for production-ready code.
However, in recent years, there has been a growing trend towards using a different default branch name, such as main
, trunk
, or default
. This is because the master
branch name has been associated with the historical context of the word "master" being used to refer to a person of authority, which can be problematic and offensive to some people.
To change the default branch name for a new Git repository, you can use the --initial-branch
option when creating the repository. For example:
git init --initial-branch=main
This will create a new Git repository with the default branch named main
instead of master
.
Alternatively, you can also change the default branch name after creating the repository by running the following command:
git branch -m master main
This will rename the master
branch to main
.
It's worth noting that changing the default branch name may require some additional configuration and updates to your Git workflow, especially if you have existing repositories or collaborators who are used to working with the master
branch.