git:错误:src refspec master与任何不匹配

参见英文答案 > src refspec master does not match any when pushing commits in git 54个
将git存储库克隆到目录“hggit”并设置远程源

mbm:hggit my name$git remote add origin [email protected]:"mystringhere"

编辑文件后,我提交了更改(位于子目录中)

mbm:handelgroup michaelmausler$git commit -m "first commit"
[master 5a29bc8] first commit
 1 files changed, 2 insertions(+), 2 deletions(-)

然后我尝试推送文件更改并收到以下错误

mbm:hggit myname$git push origin master
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:"mystringhere"'

如果git status确实表明你确实有一个活动的主分支(因为你确实做了第一次提交),检查你在定义你的远程时是否有任何拼写错误:见“Push origin master error on new repository”:

git remote rm origin

Then I recreated the origin, making sure the name of my origin was typed EXACTLY the same way my origin was spelled.

git remote add origin git@....

你可以简化:

git remote set-url origin git@....

然后,您可以在本地分支和远程跟踪分支之间建立跟踪链接:

git push -u origin master

您还可以将其推送到原点上的其他分支:

git push -u origin master:anotherBranch

你可能感兴趣的:(git:错误:src refspec master与任何不匹配)