1. 程式人生 > >Git Pull Failed: fatal: refusing to merge unrelated histories

Git Pull Failed: fatal: refusing to merge unrelated histories

碼雲提交報錯:Git Pull Failed: fatal: refusing to merge unrelated histories或者Push rejected: Push to origin/master was rejected

進入到專案資料夾目錄下,右鍵啟動Git Base here輸入下方命令  ,然後先選擇pull 把目錄下的README.md獲取下來後,然後就能提交成功了! 提交前記得先add

git pull origin master --allow-unrelated-histories

 

 

git branch --set-upstream master origin/master

 

 

 

提示“No Changes Detected”時 用vcs->git ->pull和push操作

 

出現衝突時要先解決衝突,解決衝突後再次輸入上面命令如果提示:

Exiting because of unfinished merge.

先輸入

git commit -m "commit info"

 

再次輸入上方命令

 

 

然後繼續vcs->git ->pull和push  操作。

 

error: You have not concluded your merge (MERGE_HEAD exists).的原因可能是在以前pull下來的程式碼自動合併失敗

解決辦法一:保留本地的更改,中止合併->重新合併->重新拉取

$:git merge --abort
$:git reset --merge
$:git pull
  • 解決辦法二:捨棄原生代碼,遠端版本覆蓋本地版本(慎重)
$:git fetch --all
$:git reset --hard origin/master
$:git fetch