我使用以下内容克隆存储库:

git clone ssh://xxxxx/xx.git 

但在我更改一些文件并添加和提交它们之后,我想将它们推送到服务器:

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'

当前回答

我面临着同样的问题,并尝试了这里的大多数答案,但问题是因为最近Github重命名的变化。

GitHub正在逐步将存储库的默认分支从master重命名为main。

https://github.com/github/renaming

您的新命令将是:

git push origin main

而不是:

git push origin master

其他回答

权限问题?解决方案:分叉

我收到这个错误是因为我没有对存储库的推送权限,所以我不得不分叉它,然后我在分叉的存储库上再次执行了pull、commit和push命令。

确保你正在推到正确的分支,或者有任何拼写错误。使用此命令检查当前工作分支的名称git显示分支

只需添加初始提交。遵循以下步骤:

git添加。gitcommit-m“初始提交”git推送原始主机

这对我有用。

git push-u原始主机

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

这是由于存储库仍然是空的。存储库中没有提交,因此没有主分支可以推送到服务器。

这对我有用

决议

1) git init
2)git commit -m "first commit"
3)git add app
4)git commit -m "first commit"
5)git push -u origin master

也许GitHub不知道你是谁。

首先,您必须运行:

git config --global user.email "you@example.com"
git config --global user.name "Your Name"