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

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'

当前回答

我也遇到了同样的问题,并且发现我没有提交任何文件,所以当我再次尝试提交时,我收到了以下错误消息:

*** Please tell me who you are.

Run

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

 to set your account's default identity.
 Omit --global to set the identity only in this repository.

 fatal: unable to auto-detect email address (got 'USER@WINDOWS-HE6I2CL.(none)')

然后我所做的就是在全球范围内添加我的电子邮件和姓名,然后再次提交:

git commit -m 'Initial commit'

然后按下

git push -u origin master

其他回答

在我的例子中,fastlane match nuke开发(它从git凭证存储和开发者门户中删除开发证书和配置文件)试图推送master,但我们没有master。由于我们有两个不同的团队,我们也有两个分支机构。解决问题的方法是打电话告诉match正确的分支:

fastlane match --git_branch <your_branch> nuke development

首先,您需要gitinit来创建您自己的.git文件,否则如果您克隆了某个git文件夹,它将无法识别您的git凭据。启动git后,继续执行gitadd。和gitcommit。。。

git分支使用-mv标志重命名分支:git分支-mv源主机

在这个git分支之后应该显示master

对于GitLab用户,GitLab的更新版本现在将有一个“main”分支作为默认分支。

因此,您可以尝试以下操作:

git push origin main

参考:GitLab新Git默认分支名称为main

也许分支是主分支而不是主分支。

Try

git推送原点HEAD:main

or

git推送原点主