03. git pull vs git fetch

Posted by Yulai Blog on December 1, 2015

Do you know what has done if you execute “git pull”?

git pull vs git fetch

git fetch download new branches and data from a remote repository

git pull fetch from a remote repo and try to merge into the current branch

git pull equals git fetch && git merge FETCH_HEAD

git pull --rebase equals git fetch && git rebase


HEAD names the commit on which you based the changes in the working tree.

FETCH_HEAD records the branch which you fetched from a remote repository with your last git fetch invocation.

ORIG_HEAD is created by commands that move your HEAD in a drastic way, to record the position of the HEAD before their operation, so that you can easily change the tip of the branch back to the state before you ran them.

MERGE_HEAD records the commit(s) which you are merging into your branch when you run git merge.