I cloned my repository with:
git clone ssh://xxxxx/xx.git
but after I changed some files and add
and commit
them I want to push them to 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'
This just mean you forgot to do the initial commit, try
Missing or skipping
git add .
orgit commit
may cause this error:To fix it, reinitialize and follow the proper sequence:
In case if you are facing this problem even after doing git init and pushing your initial commit. You can the try the following,
Your code will be pushed as new branch.
I faced same problem and I used
--allow-empty
.I think its because you pushed an invalid branch. Generally because the repository does not have common master branch(maybe development branch). You can use git branch to see branches.
Try
git show-ref
to see what refs do you have. Is thererefs/heads/master
?You can try
git push origin HEAD:master
as more local-reference-independent solution. This explicitly states that you want to push the local refHEAD
to the remote refmaster
(see the git-push refspec documentation).