I clone my repository with:
git clone ssh://xxxxx/xx.git But after I change some files and add and commit them, I want to push them to the server:
git add xxx.php git commit -m "TEST" git push origin master But the error I get back is:
error: src refspec master does not match any. error: failed to push some refs to 'ssh://xxxxx.com/project.git'
You need to add a file to a commit before you can push your changes to a remote Git repository. If you create a new repository and forget to add a file to a commit, you may encounter the “src refspec master does not match any” error.
The solution to this error is to either create a local and remote master branch that you can push the commit to or to push the commit to an existing branch – maybe main . These commands will create a master branch locally. And by pushing to origin master , the master branch will also be created remotely.
Solution for error: src refspec master does not match any. All you need to perform is git commit with a proper message and then do git push to the remote origin to avoid any errors.
Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“. To pull the changes from the remote repository to local, we use git pull along with remote repository “origin” and “master” branch.
Maybe you just need to commit. I ran into this when I did:
mkdir repo && cd repo git remote add origin /path/to/origin.git git add . Oops! Never committed!
git push -u origin master error: src refspec master does not match any. All I had to do was:
git commit -m "initial commit" git push origin master Success!
git show-ref to see what refs you have. Is there a refs/heads/master?Due to the recent "Replacing master with main in GitHub" action, you may notice that there is a
refs/heads/main. As a result, the following command may change fromgit push origin HEAD:mastertogit push origin HEAD:main
git push origin HEAD:master as a more local-reference-independent solution. This explicitly states that you want to push the local ref HEAD to the remote ref master (see the git-push refspec documentation).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With