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 git@code.getpantheon.com:"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 'git@code.getpantheon.com:"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
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容