Some time ago GitHub decided to rename the default branch "master" to "main" but this change may leave your Git and GitHub's out of sync, and sometimes you encounter a problem when you try to initialize your local repos with the command git init because your repo still will be using "master" and you have to change your branch manually to avoid errors and let's face it this is very tedious but
- How to change your default git branch name
To check your default git configuration let's go to ~/.gitconfig and open it or use this command
git config --global --list
Every time you initialize a repo this take your configuration and now we can change that, first, you need to create a custom directory called .git-template to do that use this command
mkdir ~/.git-template
Inside the new folder let's create a new file called HEAD without extension and put this code
ref: refs/heads/main
The final step is to execute this command
git config --global init.templateDir ~/.git-template
If everything is good, the default branch now is main
Note: If you want to learn more about GitHub check this article What is GitHub? from Chris Bongers
Thanks for reading ๐.