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

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

其他回答

我想这可能会对某人有所帮助。我今天做出了我的第一次重大承诺。我试了很多指南,但总是出错。

首先:将文件cd到目录中初始化git:gitinit提交文件:gitcommit要在有任何模糊的bash命令时强制提交,请单击I插入提交消息要继续:单击Esc

要发送到GitHub存储库,请首先确保已添加用户名和电子邮件:

git config --global user.name 'Your name'
git config --global user.email 'name@mail.com'

继续:

git remote add origin https://github repo url

要推送到存储库:

git push -u origin 'https://github.repo url'

它将提交加载到存储库中。

完成!!!

我想是因为你推了一个无效的分支。

通常,因为存储库没有公共的主分支(可能是开发分支)。您可以使用

git branch

查看分支。

当您在一个特定的分支中并尝试推送另一个尚不存在的分支时,也会发生这种情况,例如:

$ git branch
* version-x  # you are in this branch
  version-y

$ git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'origin_address'

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分支使用默认分支名称

我走错了路。检查您的分支。我在“主”分支而不是“主”。