git push origin master提交報錯解決辦法

使用git push origin master將本地提交推送到遠程倉庫的時候
遇到了這樣的一個報錯

wangting@DESKTOP-O81VEVO MINGW64 ~/Desktop/wisdom_inventory_admin (master)
$ git push origin master
To https://gitee.com/wangyoko/wisdom_inventory_admin.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/wangyoko/wisdom_inventory_admin.git'
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.

原因是遠程倉庫中的文件和我們本地的倉庫有差異,例如你的遠程倉庫有個文件Readme. md,但是本地倉庫卻沒有,就可能會出現這種情況。

本地倉庫:


遠程倉庫:


解決辦法

git pull origin master --allow-unrelated-histories

將遠程倉庫的Readme. md一起拉下來同步到本地

再次執行
git push origin master


ok,遠程倉庫同步代碼


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