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 form | What it does |
|---|---|
--all | Fetch from every remote |
-p, --prune | Delete local references to branches that were removed on the remote |
--tags | Also fetch all tags |
--depth N | Limit fetched history to N commits |
--unshallow | Turn a shallow clone into a full one |
Examples
git fetch
From github.com:ana/site
8b1d7e4..3f2a9c1 main -> origin/main
git fetch --all --prune
git log HEAD..origin/main --oneline
git fetch upstream main
Notes
- Fetch is always safe. Look at the result, then merge or rebase when ready.
- git pull is fetch followed by a merge (or rebase). Fetching first lets you review.
- Use git fetch origin pull/123/head:pr-123 to bring a GitHub pull request into a local branch.
See also
Last reviewed 2026-10-09.