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

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中看到您的更改!

其他回答

 sudo git push -v --progress "origin" : origin/prod_18aug2022

当我从本地分支机构推到远程分支机构时,这对我很有用。

权限问题?解决方案:分叉

我收到这个错误是因为我没有对存储库的推送权限,所以我不得不分叉它,然后我在分叉的存储库上再次执行了pull、commit和push命令。

此问题的另一个可能原因是您拼写错误了分支名称。因此,如果你做了我所做的,那么问题将通过纠正来解决:

git push origin mater

to

git push origin master

我也犯了类似的错误。但Git告诉我:

*** Please tell me who you are.

Run

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

或设置帐户的默认身份。

Omit --global to set the identity only in this repository.

然后错误消失。

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

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