Git Fetch vs Git Pull: What's the Difference?
git fetch downloads new commits from GitHub without touching your work. git pull downloads them and immediately merges (or rebases) them into your branch. When to use each, what origin/main actually is, and how to see what changed before you pull.
Both commands get new work from GitHub (or wherever your remote lives). The difference is what happens next:
git fetchdownloads the new commits and stops. Your files and your branch don't change.git pulldownloads them and merges them into your current branch. Your files change.
In fact, git pull is literally git fetch followed by git merge (or git rebase, if configured).
What fetch actually updates
Your repository keeps a copy of what the remote looked like the last time you talked to it. These are remote-tracking branches, named like origin/main:
main— your local branch. Changes when you commit.origin/main— your computer's snapshot of GitHub'smain. Changes only when you fetch or pull.
git fetch updates origin/main (and every other origin/...) to match GitHub. Your main stays exactly where it was.
That's why git status can say "Your branch is up to date with 'origin/main'" when it isn't — it's comparing against a snapshot you haven't refreshed. Run git fetch first and it'll tell the truth.
Why fetch first?
Fetch lets you look before you leap:
git fetch
git log main..origin/main --oneline # commits on GitHub you don't have
git diff main origin/main # what they change
Then decide: merge them, rebase onto them, or deal with them later. Useful when you're mid-task, when a teammate (or an AI agent) has been pushing a lot, or when you want to review incoming changes. (How to read a diff)
After looking, bring them in:
git merge origin/main
# or
git rebase origin/main
When pull is fine
Most of the time, on a branch only you use or when you just want the latest, git pull is exactly right. Do it at the start of each session:
git switch main
git pull
Merge or rebase on pull
When your branch and the remote have both moved, pull has to combine them. You choose how:
git pull --rebase # replay your commits on top: linear history
git pull --no-rebase # create a merge commit
git pull --ff-only # only proceed if no combining is needed; otherwise stop
Set a default once:
git config --global pull.rebase true
--ff-only is the cautious choice: it never creates a merge commit or rewrites anything, and it fails loudly when branches have diverged, so you can decide. (Git rebase vs merge)
Pull with uncommitted changes
If your uncommitted changes touch the same files as the incoming commits, git refuses to pull. Commit them, or stash them:
git stash
git pull
git stash pop
Quick reference
| You want to | Run |
|---|---|
| See if there's anything new, safely | git fetch then git status |
| List incoming commits | git log main..origin/main --oneline |
| Get the latest and carry on | git pull |
| Get the latest, never auto-merge | git pull --ff-only |
| Update all remote branches, remove deleted ones | git fetch --all --prune |
The summary
fetchdownloads and updatesorigin/*; your work is untouched.pull= fetch + merge (or rebase) into your current branch.- Fetch first when you want to see what's coming.
git statusonly knows about the remote as of your last fetch.
EasySpawn keeps your repository on a persistent server where you and Claude Code share the same branches, so there's less to fetch and nothing lost between sessions. See how it works or join the waitlist.
Related: Git and GitHub for Beginners · Git Push Rejected · Git Branches Explained · Git Rebase vs Merge · "You Have Divergent Branches" · "Your Branch Is Behind origin/main" · git commit --amend
Keep reading
What Is nvm? Install and Switch Node.js Versions the Easy Way
nvm (Node Version Manager) lets you install several versions of Node.js and switch between them per project. How to install it on Mac and Linux, the Windows options, the commands you'll actually use, .nvmrc files, and alternatives like fnm and Volta.
What Is n8n? Workflow Automation (and AI Agents) Explained Simply
n8n is a workflow automation tool: you connect apps and APIs with visual nodes so that something happening in one place triggers actions in others. What n8n is used for, how workflows and nodes work, its AI agent features, the fair-code licence, and cloud vs self-hosted.