I recently created a new project and noticed that my git init
created the default branch as master
. I wanted to rename this to main
.
So I typed the simple git branch -m master main
but then I got this error:
error: refname refs/heads/master not found
fatal: Branch rename failed
I was confused, but then it hit me… I hadn’t actually committed anything yet so my branch didn’t actually exist! As soon as I committed something, my branch rename worked fine.
Hope this helps someone else.