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

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已经将“Master”更改为“Main”,因此请确保您通过以下方式进行推送:

git push origin main

其他回答

如果你在第一次推之前忘记承诺,就会发生这种情况。只需运行:

git commit -m "first commit"

我也有同样的问题。我通过以下步骤做到了这一点:

1. git commit -m 'message'
2. git config --global user.email "your mail"
3. git config --global user.name "name"
4. git commit -m 'message'
5. git push -u origin master

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

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

这对我有用。

我在尝试将内容推送到GitHub上的新存储库时遇到了这个错误。我在本地创建了Git存储库,并且使用Web GUI(包括一个LICENSE文件)在GitHub上创建了存储库。

在我将LICENSE文件从原本空的GitHub存储库拉到本地存储库后,问题消失了。之后,我可以毫无问题地推进。

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

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