git fetch
Download latest commits and branch info from remote without auto-merging into local branches
Syntax
git fetch [<remote>] [<refspec>...]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
--all |
New | |
Common |
--prune |
|
Common | |
--tags |
|
Common | |
--depth <n> |
() | |
Common |
--dry-run |
, | |
Common |
Examples
origin New
git fetch origin
New
git fetch --all
New
git fetch --prune
main New
git fetch origin main
fork
git fetch upstream && git merge upstream/main
Tips
- fetch, and
- git pull = git fetch + git merge, fetch
- fetch --prune
- fetch git log origin/main.main