Git fetch和git pull的區別, 解決Git報錯:error: You have not concluded your merge (MERGE_HEAD exists).
2017年02月22日 20:38:28
閱讀數:19178
Git fetch和git pull的區別:
都可以從遠程獲取最新版本到本地
1.Git fetch:只是從遠程獲取最新版本到本地,不會merge
(合並)
$:git fetch origin master
2.Git fetch:從遠程獲取最新版本並merge
(合並)到本地
$:git pull origin master
實際工作中,可能git fetch
更好一些, 因為在merge
前,可以根據實際情況決定是否merge
再說導致報錯: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