如何解決failed to push some refs to git


$ 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.

 

出現錯誤的主要原因是github中的README.md文件不在本地代碼目錄中

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

git pull --rebase origin master

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

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM