Progress:
TIER 1 · MODULE 19· Basics

git fetch

The non-destructive half of git pull.

🎯 What & why

Download new commits, trees, blobs, and refs from a remote — but don't change your working tree or current branch. The non-destructive half of git pull.

🧠 Mental model

Fetch updates refs/remotes/<remote>/*. Your local branches and working tree are untouched. After fetch, git log @{u}..HEAD (commits you have that upstream doesn't) and git log HEAD..@{u} (commits upstream has that you don't) become meaningful queries.

🛠️ Synopsis

git fetch [<options>] [<repository> [<refspec>...]]
git fetch [<options>] <group>
git fetch --multiple [<options>] [(<repository> | <group>)...]
git fetch --all [<options>]

🎚️ Switches & options

FlagWhat it does
--allFetch from all remotes.
--prune, -pDelete local remote-tracking branches whose remotes are gone.
--tagsFetch tags.
--depth=<n>Shallow fetch.
--unshallowConvert a shallow clone to a full one.
--dry-runShow what would happen.

💡 Use cases

🧪 Examples

Fetch from origin.
$ git fetch
Fetch and prune deleted upstream branches.
$ git fetch --prune
Fetch a specific branch into a tracking ref.
$ git fetch origin feature/login:refs/remotes/origin/feature/login

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.