我克隆了我的存储库:
git clone ssh://xxxxx/xx.git但在我更改了一些文件并add并commit它们后,我想将它们推送到服务器:
git add xxx.php
git commit -m "TEST"
git push origin master但我得到的错误是:
error: src refspec master does not match any.
error: failed to push some refs to 'ssh://xxxxx.com/project.git'
也许你只需要提交。我做的时候碰到了这个:
mkdir repo && cd repo
git remote add origin /path/to/origin.git
git add .哎呀!从不承诺!
git push -u origin master
error: src refspec master does not match any.我所要做的就是:
git commit -m "initial commit"
git push origin master成功!
试试git show-ref ,看看你有什么样的参考资料。有refs/heads/master吗?
您可以尝试使用git push origin HEAD:master作为更多本地参考独立的解决方案。这明确指出您希望将本地 ref HEAD推送到远程 ref master (请参阅git-push refspec文档)。
删除本地计算机中的所有文件后,我也遇到了类似的错误,我必须清理存储库中的所有文件。
我的错误信息是这样的:
error: src refspec master does not match any.
error: failed to push some refs to 'git@github ... .git'并通过执行以下命令解决:
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.就是这样,希望这会有所帮助。