Github error: src refspec master does not match any

Dung Do Tien Apr 21 2022 526

Hello Guys, I have a project with .Net 6 and use GitHub to help manage source code. The first time I clone code to my local computer and I have added some features to the source code. Now I need to commit code, I try:

git add .
git commit -m "Add more feature to project"
git push origin master

But I got an error throw error: src refspec master does not match any

error: src refspec master does not match any.  
error: failed to push some refs to ''

I tried to git push it's worked for me. But I want to push directly to the origin not on local

I don't know how to fix it. Thank for any solution.

Have 3 answer(s) found.
  • L

    Linh Mai Apr 21 2022

    You can run command git show-ref

    1. if it returns refs/heads/master you can run command git push origin HEAD:master

    2. if it returns refs/heads/main you can run command git push origin HEAD:main

    I got the same error and solve by this way.

  • M

    Marry Christ Apr 21 2022

    Not sure but maybe the branch is main instead of master

    Please change to:

    git push origin HEAD:main 
    git push origin main

    I hope it's work for you

  • M

    Mohammed Waseem Apr 21 2022

    I really got the same error, It's mean you have no branch name "master".  You need to recheck what is the current branch name? 

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close