[轉(zhuǎn)載]如何解決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.

方法
在使用git 對(duì)源代碼進(jìn)行push到gitHub時(shí)可能會(huì)出錯(cuò),信息如下

此時(shí)很多人會(huì)嘗試下面的命令把當(dāng)前分支代碼上傳到master分支上。

$ git push -u origin master
但依然沒(méi)能解決問(wèn)題

出現(xiàn)錯(cuò)誤的主要原因是github中的README.md文件不在本地代碼目錄中

可以通過(guò)如下命令進(jìn)行代碼合并【注:pull=fetch+merge]

git pull --rebase origin master

執(zhí)行上面代碼后可以看到本地代碼庫(kù)中多了README.md文件


如何解決failed to push some refs to git

此時(shí)再執(zhí)行語(yǔ)句 git push -u origin master即可完成代碼上傳到github

[
如何解決failed to push some refs to git

http://jingyan.baidu.com/article/f3e34a12a25bc8f5ea65354a.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容