Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get rid of the message "Heads up! The branch 'master' that you pushed to was renamed to 'main'" when pushing changes to git?

When pushing to github, I seem to always get a "Heads up!" message (below) that tells me that my master branch was renamed to main. But I see no main branch on the remote origin repository.

Message Example

$ git push -f
...
remote:
remote: Heads up! The branch 'master' that you pushed to was renamed to 'main'.
remote:

I've checked everything I could think of and there is no main branch on origin, there is no main branch on local. Where is that message coming from?

Here is a listing of my branches:

$ git branch --all
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

Solutions Tried

I tried using git branch -u origin/master I've seen suggested elsewhere, but it did not help.

like image 319
Dennis Avatar asked Oct 14 '25 05:10

Dennis


1 Answers

I solved it by issuing a series of commands:

First, I renamed master to random on Github, and then I ran

git branch -m random
git push origin HEAD -f # pushed changes to new branch "random"

git push origin :master # deleted master that was hanging there somehow

git commit --amend -a --no-edit # to force a commit change
git push -u origin random -f # no message!

I then reversed this process => renamed branch random to master on GitHub, and

git push origin :random
git branch -m master
git push -u origin master
git remote prune origin
git push

no more message!

like image 179
Dennis Avatar answered Oct 19 '25 15:10

Dennis