git push ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/Operater9/guest' hint: Updates were rejected because the tip of your current bra


推送本地代碼到github報錯

git push報錯

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Operater9/guest'
hint: Updates were rejected because the tip of your current branch is behind
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.

查了資料后發現是本地沒有update到最新版本的項目(git上有README.md文件沒下載下來)

本地直接push所以會出錯。

 

執行下面的拉命令,還是不行

$ git pull origin master
From https://github.com/Operater9/guest
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

 

執行下面代碼

參考https://stackoverflow.com/questions/24114676/git-error-failed-to-push-some-refs-to

git pull --rebase origin master

發現此時已經把github上最新的文件下載下來了:也就是README.md文件。

 

接着執行推送

git push -u origin master

成功推送本地代碼到遠程倉庫

參考https://blog.csdn.net/u013120247/article/details/53263169

 


免責聲明!

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



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