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

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'

当前回答

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

其他回答

如果您是第一次使用Git,则需要配置Git安装,包括:

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

git config --global user.name "Your Name"

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

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

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

这只是意味着你忘了做初始提交,试试

git add .
git commit -m 'initial commit'
git push origin master

我遇到了这个错误,因为我使用了字符“&”,所以分支的名称有问题。我只是跳过了“^&”,它起了作用。