問題描述:
關於Git的使用,在通常情況下,習慣於先在本地創建一個本地倉庫,然后將項目提交到本地master,再將本地master中的項目Push 到遠程倉庫中,這樣問題就來了。
具體錯誤信息如下:
git.exe push --progress "origin" master
To https://github.com/Jackson-AndyLau/CMSManager.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Jackson-AndyLau/CMSManager.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 did not exit cleanly (exit code 1) (12359 ms @ 2018-07-01 09:41:24)
如下圖所示:
解決辦法:
關於這個問題,在網上搜羅了一下,很多工程師都遇到過,解決方法也是五花八門,要不刪除一些文件,要不修改一些配置文件,但最終還是未能解決問題。
后來經過多次的嘗試,終於找到了解決辦法,這兒分享出來,希望能幫助到你,能少花費些時間去看那些無用的方法!!!
1、根據錯誤內容提示,先將遠程新建的空倉庫 “ Clone ” 到本地,會得到一個空的與遠程倉庫對應的目錄,如下圖:
2、然后將文件提交到master,再Push到遠程倉庫,發現問題解決了額, 如下圖:
再看遠程倉庫:
————————————————
版權聲明:本文為CSDN博主「csdn-華仔」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/hello_world_qwp/article/details/80872257