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

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'

当前回答

更新答案:确保所有更改都已提交。

然后键入:gitpush在这之前,请确保创建一个个人访问令牌,GitHub现在使用这个。然后键入您的GitHub用户名(键入gitpush后),然后将您的个人访问令牌粘贴到密码输入中。

所有这些之后,您应该可以在GitHub中看到您的更改!

其他回答

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

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

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

对我来说,只需签出我希望代码推送的分支,然后简单地推送您的代码。

git checkout -b branchname-on-which-i-will-push-my-code

git add .
git commit -m "my commit message"
git push origin branchname-on-which-i-will-push-my-code

我也犯了同样的错误;我的问题就是这样解决的:

git config --global user.email "YOUR EMAIL"
git config --global user.name "YOUR NAME"

我也遇到过同样的问题,这解决了我的问题:

只需制作一个分支:

git checkout-b“master”

之后,

git push-u原始主机

繁荣