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

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'

当前回答

如果它没有识别出您有一个主分支,只需创建它并再次提交。

要创建主分支,请执行以下操作:

git checkout -b master

其他回答

此问题的另一个可能原因是您拼写错误了分支名称。因此,如果你做了我所做的,那么问题将通过纠正来解决:

git push origin mater

to

git push origin master

当您添加了文件,忘记提交和推送时,就会发生这种情况。所以提交文件,然后推送。

来自Git的错误:

错误:src-refspec-master与任何不匹配。

已修复此步骤:

git commit -m "first commit"

在我跑步之前:

git add <files>

在我跑步后:

git push -u origin master

也许GitHub不知道你是谁。

首先,您必须运行:

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

这只是意味着你忘了做初始提交,试试

git add .
git commit -m 'initial commit'
git push origin master