Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: src refspec main does not match any

Tags:

git

github

I have a local branch named master and its upstream is set to origin/main

But whenever I push to remote repo using git push -u origin main it shows error:

error: src refspec main does not match any error: failed to push some refs to

But it works fine when I use git push -u origin HEAD:main

So what's the Problem in here?

like image 811
35_Khushal Makhija Avatar asked May 23 '26 05:05

35_Khushal Makhija


1 Answers

git push origin main means "push local branch main" and you don't have local branch main, you have master. After the first git push -u origin master:main you should push using git push origin or even bare git push. Or continue pushing using git push origin master:main

like image 134
phd Avatar answered May 25 '26 22:05

phd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!