如何解决failed to push some refs to git
?
- 1
- 2
- 3
- 4
- 5
- 6
- 7
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
方法/步驟
在使用git 對源代碼進(jìn)行push到gitHub時(shí)可能會出錯(cuò),信息如下
此時(shí)很多人會嘗試下面的命令把當(dāng)前分支代碼上傳到master分支上。
$ git push -u origin master
但依然沒能解決問題
出現(xiàn)錯(cuò)誤的主要原因是github中的README.md文件不在本地代碼目錄中
可以通過如下命令進(jìn)行代碼合并【注:pull=fetch+merge]
git pull --rebase origin master
執(zhí)行上面代碼后可以看到本地代碼庫中多了README.md文件
此時(shí)再執(zhí)行語句?git push -u origin master即可完成代碼上傳到github
END轉(zhuǎn)載于:https://www.cnblogs.com/lykbk/p/scscscwe3r34.html
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的如何解决failed to push some refs to git的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自然语言处理在医学领域的应用
- 下一篇: forEach 与 map 的区别