Repaso
EspaƱol

What is the difference between git fetch and git pull?

Options

  1. There is no difference, they do the same thing
  2. fetch downloads only; pull is fetch plus merge (Correct option)
  3. pull uploads your changes; fetch deletes them
  4. fetch only works for tags, not for branches

Answer

fetch downloads remote changes without changing your files; pull = fetch + merge into your current branch

Why

git fetch updates your knowledge of the remote (new commits and branches) but does not touch your working files. It is safe: you can inspect first (git log origin/main).

git pull does fetch and then merges (or rebases, with --rebase) those changes into your current branch immediately. It may cause conflicts you must resolve.

Many people use git pull --rebase to keep a linear history.

Remember

pull = fetch + merge.

Key terms

Practice this question in Repaso