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

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 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

其他回答

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

我错过跑步时也遇到了同样的问题:

git add .

(必须至少有一个文件,否则会再次出现错误。)

当我没有提到起源的主分支时,这发生在我身上。因此,您可以尝试以下操作:

git pull origin master

这将在本地存储库中创建对源的主分支的引用。然后,您可以将本地存储库推送到源位置。

git push -u origin master

也许GitHub不知道你是谁。

首先,您必须运行:

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

也许你只需要承诺。当我这样做的时候,我遇到了:

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 main

成功