error: refname refs/heads/HEAD not found
fatal: Branch rename failed
$ git checkout -b main
git fetch
git reset --hard origin/master
I get into this issue too. The reason is that I didn't have any commit on this
git repository.
When I run the command git branch -M main. I get the following error message.
error: refname refs/heads/master not found
fatal: Branch rename failed
After I add my first commit by the following command, all things works.
git add .
git commit -m 'Init'
//make sure everything is commited before
git add .
git commit -m 'Init'
try
git push -u origin main
instead of
// git push -u origin master
git add .
git commit -m 'Init'