Defaulting Visual Studio git branch to main

For some time, I had been generating my Git repositories using Visual Studio, which automatically generated a “master” branch. Subsequently, I would create a “main” branch, push it, and following that, delete the “master” branch. All this time, I mistakenly believed that this behavior was determined by Visual Studio. However, I recently learned that this is actually a global Git configuration setting, which can be updated with a single command.

git config --global init.defaultBranch main

Well, this will save me 3-4 minutes every time I initialize a new repository.

Leave a comment