git fetch Download new commits without changing your files

Gets the latest commits and branches from a remote and updates your remote-tracking branches such as origin/main. Your own branches and working folder stay as they are.

Synopsis

git fetch [OPTION]... [REMOTE [BRANCH]]

Common options

Option or formWhat it does
--allFetch from every remote
-p, --pruneDelete local references to branches that were removed on the remote
--tagsAlso fetch all tags
--depth NLimit fetched history to N commits
--unshallowTurn a shallow clone into a full one

Examples

Get the latest from origin
git fetch
From github.com:ana/site
   8b1d7e4..3f2a9c1  main       -> origin/main
Fetch everything and tidy up
git fetch --all --prune
See what you do not have yet
git log HEAD..origin/main --oneline
Fetch one branch of a remote
git fetch upstream main

Notes

See also

Last reviewed 2026-10-09.