Git——git push 错误[ ! [rejected] master - master (non-fast-forward)]解决方案
生活随笔
收集整理的這篇文章主要介紹了
Git——git push 错误[ ! [rejected] master - master (non-fast-forward)]解决方案
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題描述?
git push -u origin master To https://github.com/XXX/XXX.git! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/XXX/XXX.git' 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.問題分析
Git倉庫中已經有一部分代碼,所以它不允許你直接把你的代碼覆蓋上去。
遠程倉庫和本地倉庫存在差異。
解決方案
方法一:同步
1、git pull origin master --allow-unrelated-histories?//把遠程倉庫和本地同步,消除差異
2、重新add和commit相應文件
3、git push origin master
4、此時就能夠上傳成功了
方法二:強推
即利用強覆蓋方式用你本地的代碼替代git倉庫內的內容
git push -f origin master方法三:
先把git的東西fetch到你本地然后merge后再push
git fetch git merge?
參考文章
https://blog.csdn.net/xieneng2004/article/details/81044371
https://blog.csdn.net/zyz00000000/article/details/84402189
https://www.jianshu.com/p/f26c71d05e44
總結
以上是生活随笔為你收集整理的Git——git push 错误[ ! [rejected] master - master (non-fast-forward)]解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Git——git push 错误[err
- 下一篇: Git——Git基本教程