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

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'

当前回答

如果您在Windows上使用GitBash,请尝试重新启动它。它对我有用!

其他回答

尝试git show ref

你可能会看到refs/heads/live

这意味着你应该这样做

git push -u origin live

GitHub更新01.10.20后,您应该使用main而不是master。

这样做。。。

在GitHub上创建存储库删除本地目录中现有的.git文件转到本地项目目录并键入gitinitgit添加。gitcommit-m“我的第一次通信”现在检查您的分支机构名称,它将在您的本地项目中处于主导地位gitremoteadd origin<github存储库中的远程存储库URL>,然后键入gitremote-vgit push-f原始主机现在检查github存储库,您将看到两个分支1。主要2。主人在本地存储库中创建新分支,分支名称将为maingit结帐总管git合并主机git拉起点总管git push-f origin main

注意:从2010年10月1日起,github决定使用main而不是master分支使用默认分支名称

Github将默认分支名称从master更改为main。因此,如果您最近创建了回购,请尝试推送主分支

git push origin main

Github文章

截至2020年10月1日,GitHub正在将主分支的名称更改为main。这就是导致问题的原因。当有人键入git push origin master时,他们会看到此错误错误:src refspec master与任何错误都不匹配:未能将某些ref推送到'https://github.com/username/reponame.git'

这可以通过使用git push origin main来解决。希望这有帮助。我花了很长时间才弄明白为什么我不能将我的承诺提交给主分支。

首先,确保您使用的是master分支。在我的案例中,分支是主分支而不是主分支。所以我做的是

git push origin main

你可以在这张照片中看到结果