Difference between Git fetch and Git pull: Error: You have not concluded your merge (MERGE_HEAD exists)
The difference between FETCH and pull is that you can fetch the latest version from remote to local
1. Fetch: only fetch the latest version from remote to local, not merge
(merge)
git fetch origin master //Get the latest version on the origin/master branch from the master master branch on a remote origin.
git log -p master..origin/master //Compare the difference between a local master branch and an origin/master branch.
git merge origin/master //consolidation
2. Pull: get the latest version remotely and merge
(merge) locally
git pull origin master //This is equivalent to doing a git fetch and a git merge.
In practice, it may be better to git fetch
, because before merge
, it can be decided whether to merge
according to the actual situation
Besides, it causes error: error: You have not concluded your merge (MERGE_HEAD exists).
may be caused by the failure of automatically merging the code pulled down before
Solution 1: keep the local changes and abort the merge -& GT; Re-amalgamate -& GT; To pull
git merge --abort //Termination of pooling
git reset --merge //re-merger
git pull //refetch
Solution 2: Abandon the local code, and the remote version overwrites the local version (careful)
git fetch --all
git reset --hard origin/master
git fetch