git fetch
intermediateDownload the remote's objects — without merging, without touching your work.
git fetchWhat it does
git fetch connects to a remote, downloads whatever objects it has that you don't, and updates your remote-tracking refs (refs/remotes/origin/*). Your working tree, your index, your own branches — all untouched. Pull's harmless, half-remembered cousin; the one that never surprises you.
Your machine
local repository
Remote origin
everything.git
Only new objects travel down; your branch and worktree stay put
Watch it — press play
A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.
Step 1
See without changing
You want to peek at the remote's new commits without disturbing anything you're doing.
git fetchYour machine
local repository
Remote origin
everything.git
Objects download; your branch and files stay put
Under the hood
Object negotiation first
Fetch tells the remote which objects it already has ('want/dontwant'), so only the missing ones stream down — usually packed into one packfile, delta-compressed.
Refs update, branches don't
After objects land, fetch moves refs/remotes/origin/main forward (non-fast-forward refs are rejected as 'forced update' unless configured). Your local main still points at your own commits. Observe: nothing you're stood on moves.
The quiet inspection
`git fetch && git diff origin/main` is the 'show me what's coming WITHOUT changing anything' pattern — peer-reviewed-by-nobody-proof you can always see the future before you commit to it.
Aliases the pros type
Memorize the git fetch concept, then let one of these shortcuts make it instant. Aliases are real git config keys — add one with:
git config --global alias.st # → git fetch --all --pruneg fgit fetch --all --pruneThe always-safe sync: everything, cleaned.
g fagit fetch --allEvery remote, no pruning.
g fapgit fetch --all --pruneOh-my-zsh convention: fetch everything, drop the ghosts.
Command anatomy
--allFetch from every configured remote at once.
--pruneDelete local refs whose remote counterparts vanished.
<remote> <refspec>Fetch specific branches only.
When to reach for it
Just looking: see origin/main's new commits before you rebase onto them.
Syncing remote-tracking info when you're on a worktree you must not disturb.
Multi-remote projects: fetch upstream to keep the fork current.
Pro tip
To see the future without changing a thing: `git fetch` then `git log HEAD..origin/main --oneline`. Range syntax 'HEAD..origin/main' means 'commits I don't have yet' — a pure, side-effect-free preview of the pull you're about to do.