LearnThatStack Ace your next interview
Git & Version Control · question
Question 7 of 54

What is the difference between git fetch and git pull?

beginner
← All Git & Version Control questions
Re-explain
Visual ↓

git fetch only downloads new commits, while git pull downloads them and then integrates them into your current branch. Fetch updates your remote-tracking branches, local copies like origin/main. Fetch never changes your working files or your own branches, so it is always safe to run.

Pull integrates the upstream, the remote branch your branch tracks, and how it does that depends on your settings. By default current Git only fast-forwards, moving your branch ahead when you have no new commits of your own. A pull fails when your branch has diverged. git pull --rebase replays your commits on top instead, and git pull --no-rebase runs a merge. Set pull.rebase once to choose a default.

Command Updates origin/main Moves your branch Can conflict
git fetch yes no no
git pull yes yes yes

Fetching first lets you see what arrived before you decide how to combine it:

git fetch origin
git log --oneline main..origin/main   # what arrived
git merge origin/main                 # the step git pull --no-rebase does for you
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for Git & Version Control One question at a time. Answer out loud, get graded, see what you missed.
See it - interactive diagram
Three pointers through git fetch and git merge
git fetch origin
git log main..origin/main
git merge origin/main
Serverthe remote, origin
mainC3
Your cloneyour machine
origin/mainC1
mainC1
Console
1step

A teammate pushed commits C2 and C3 to the server. Your clone has not asked yet, so both your branch names still point at C1.

1 / 4

Fetch only moves origin/main, your copy of the server's branch. Your own main moves at the merge step, which is the part git pull adds.

© LearnThatStack - diagrams may not be republished without permission.

Other questions have diagrams like this too. Sign in to ask for one where it's missing - it's free.

Create a free account
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. git fetch only downloads new commits from the remote, while git pull downloads them and then integrates them into the branch you're on.
  2. Fetch updates your remote-tracking branches, like origin/main, and never touches your working files or your own branches, so it's always safe to run.
  3. Pull integrates your upstream, the remote branch yours tracks. By default current Git only fast-forwards, so if your branch has diverged, the pull just fails.
  4. When that happens, git pull --rebase replays your commits on top, git pull --no-rebase runs a merge, and setting pull.rebase once picks your default.
  5. I usually fetch first and run git log main..origin/main to see what arrived, then merge or rebase on purpose, because pull can hit conflicts and fetch never can.

Weak answers to avoid

  • Says pull is just fetch plus merge It misses that the integrate step depends on settings. Current Git only fast-forwards by default and fails on divergence. --rebase and --no-rebase pick the method.
  • Thinks fetch updates the local branch Fetch only moves origin/main. Your main and your files stay where they are until you merge or rebase, which is why fetch is always safe to run.
  • Treats pull as being as safe as fetch Pull moves your branch, and a merge or rebase can stop on conflicts. Only fetch is guaranteed to leave your branches and files alone.
  • Calls fetch pointless and always pulls Fetching first lets you check what arrived with git log main..origin/main before you choose to merge or rebase. Say why that extra step is worth it.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Git & Version Control cheatsheet.

← Back to all Git & Version Control questions
Pro · $10/mo

47 of 54 Git & Version Control answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime