[轉載]如何解決failed to push some refs to git

Administrator@PC-20150110FGWU /K/cocos2d/yc (master)

$ git push -u origin master

To git@github.com:yangchao0718/cocos2d.git

! [rejected]? ? ? ? master -> master (non-fast-forward)

error: failed to push some refs to 'git@github.com:yangchao0718/cocos2d.git

hint: Updates were rejected because the tip of your current branch is behin

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

如何解決failed to push some refs to git
方法

在使用git 對源代碼進行push到gitHub時可能會出錯,信息如下

如何解決failed to push some refs to git
此時很多人會嘗試下面的命令把當前分支代碼上傳到master分支上。

$ git push -u origin master

但依然沒能解決問題

如何解決failed to push some refs to git
出現錯誤的主要原因是github中的README.md文件不在本地代碼目錄中

可以通過如下命令進行代碼合并【注:pull=fetch+merge]

git pull --rebase origin master

執行上面代碼后可以看到本地代碼庫中多了README.md文件

如何解決failed to push some refs to git

如何解決failed to push some refs to git

此時再執行語句 git push -u origin master即可完成代碼上傳到github

[

如何解決failed to push some refs to git

原文地址?

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容