All commands

git fetch

intermediate

Download the remote's objects — without merging, without touching your work.

What 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

mainuntouched ✓
new objects downloaded ← origin/main

Remote origin

everything.git

refs/heads/main

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.

1 / 3

Step 1

See without changing

You want to peek at the remote's new commits without disturbing anything you're doing.

git fetch

Your machine

local repository

mainuntouched ✓
new objects downloaded ← origin/main

Remote origin

everything.git

refs/heads/main

Objects download; your branch and files stay put

Under the hood

1

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.

2

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.

3

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 --prune
AliasWhy people use it
g f

The always-safe sync: everything, cleaned.

g fa

Every remote, no pruning.

g fap

Oh-my-zsh convention: fetch everything, drop the ghosts.

Command anatomy

git fetch [<remote>]
--all

Fetch from every configured remote at once.

--prune

Delete 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.

Go deeper with