git提交到github衝突解決

git提交代碼到github衝突解決

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解決方法

解決方案一.正常解決推薦

git fetch origin  //更新遠程倉庫文件

git diff master origin/master  //本地文件和遠程倉庫文件進行對比

git merge origin/master  //自動合併

解決方案二:強制推送( **會覆蓋衝突以這次爲準,不建議 ** )

$ git push -f 

解決方案三:(強制覆蓋本地代碼,你自己修改的代碼即將被遠程庫的代碼所覆蓋)

把你修改的代碼進行備份,然後執行命令:

git reset --hard origin/master
git pull

tip:除了git log之外還有一個很好用“gitk”界面化展示提交log記錄

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章