By google-ing, we'd find a simple command as
git branch -m master main which should rename the
master branch to
What if it was not successful and you had,
error: refname refs/heads/master not found fatal: Branch rename failed
Well, in my case, I create a new project then I initialized git. I then remembered that by default, on Github, the default branch is
main and not
You can change the name from
main in few steps, locally before you even make a commit.
- Navigate to the directory where your project sits.
- In it, show hidden file since by default,
.gitwould be hidden.
.git, there is a file,
HEAD, open it in a text editor. You'd see,
- Simple enough, change,
We just renamed the
master branch as
main. Verify this merely by entering,
git branch from the terminal.