The short and easy answer is that git pull
is simply git fetch
followed by git merge
.
It is very important to note that git pull
will automatically merge whether you like it or not. This could, of course, result in merge conflicts. Let's say your remote is origin
and your branch is master
. If you git diff origin/master
before pulling, you should have some idea of potential merge conflicts and could prepare your local branch accordingly.
In addition to pulling and pushing, some workflows involve git rebase
, such as this one, which I paraphrase from the linked article:
git pull origin master
git checkout foo-branch
git rebase master
git push origin foo-branch
If you find yourself in such a situation, you may be tempted to git pull --rebase
. Unless you really, really know what you are doing, I would advise against that. This warning is from the man
page for git-pull
, version 2.3.5
:
This is a potentially dangerous mode of operation. It rewrites
history, which does not bode well when you published that history
already. Do not use this option unless you have read git-rebase(1)
carefully.