When I pushing commits in Git encounters the Error: src refspec master does not match any.
The situation is that:
I use the git command to clone my repository, the command line as below:
git clone ssh://xxxxx/xx.git
Then, I change some files and
commit its. I push them to the server using the below command:
git add xxx.php git commit -m "TEST" git push origin master
However, I get the error: src refspec master does not match any.
error: src refspec master does not match any. error: failed to push some refs to 'ssh://xxxxx.com/project.git'
It looks like a very specific issue about pushing a local branch to a remote branch. Then how to solve the failed to push some refs to github error.
Here are a few solutions to ‘src refspec master does not match any.’ and ‘failed to push some refs to ‘ssh://xxxxx.com/project.git”.
- You can try
git show-refto see what refs you have. Is there a
git push origin HEAD:masteras a more local-reference-independent solution. Which explicitly states that you want to push the local ref
HEADto the remote ref
You can try executing the below commands to slove the src refspec doesn’t match any error:
touch README git add README git add (all other files) git commit -m 'reinitialized files' git push origin master --force # <- caution, --force can delete others work.
git push -u origin master error: src refspec master does not match any.
You can try the following commit command and then push the code:
git commit -m "initial commit" git push origin master
You will see the branch successfully pushed to the master branch.
Learn more about the git command.
Solutions to related error:
- Src refspec doesn’t match any
- error: failed to push some refs to
- failed to push some refs to github
- git failed to push some refs
- git push origin master not working