Unfuddle STACK Tips & Tricks
What is the difference between fetch and pull?
The two commands are similar in that they download new data from the remote. However, while
git-fetch can be called multiple times without affecting the local working copy,
git-pull will do a bit more work, updating the local HEAD with the data it downloaded.
In other words,
git-pull performs a
git-fetch followed by a
git merge FETCH_HEAD.
# fetch from origin $ git fetch origin From REMOTE_URL af74f3043..b0a88d920 master -> origin/master
# pull to local branch $ git pull origin master From REMOTE_URL * branch master -> FETCH_HEAD Removing oldfile.txt Auto-merging existingfile.txt
When attempting to perform a
git-pull in a local branch that may cause conflicts while merging, your repository will be left in a staging state until the conflicts are resolved.
# pull to local branch $ git pull origin master From REMOTE_URL * branch master -> FETCH_HEAD Removing oldfile.txt Auto-merging existingfile.txt CONFLICT (content): Merge conflict in anotherexistingfile.txt