We should probably close this as a duplicate, but before that happens let me see if I can do this.
While git pull really git fetch followed by git merge (or git rebase ), the exact difference is how git pull works git fetch .
In particular:
$ git pull
or
$ git pull remote-name branch-name
(or various similar options), not just git fetch , not git fetch remote-name , but git fetch remote-name branch-name .
This has less difference since Git is version 1.8.4 than it was before this version:
git fetch origin master , unlike git fetch origin or git fetch did not update refs/remotes/origin/master ; it was an early decision to develop the update of remote tracking branches predictable, but in practice it turns out that people find it more convenient for an opportunistic update, when we have and we update them when we run git push , which in any case violates the original “predictability”.
In other words, if git pull decides to run git fetch origin master , it will update origin/master in your repository, but only if you are not using older versions of Git, such as those included in some unnamed Linux distributions.
If you run git fetch origin , you will get all the remote tracking branches (assuming you have a reasonable configuration, which is used by default even in older versions of Git). If you run git fetch origin master you will only get origin/master and again only if your Git is not too ridiculously outdated. Since git pull runs a four-word variant, it updates only one branch of remote tracking or not.
torek source share