git fetch
Download new commits from the server without touching your branches
What it does
git fetch brings new commits and branches from the server but leaves your branches and files alone. What it downloads lives in branches like origin/main: look at them with git log origin/main or compare them with your branch, then decide how to combine.
It is a safe command: run it any time, even with uncommitted edits. --prune also removes your origin/… branches that were deleted on the server. git pull is the same fetch followed straight away by a merge.
Syntax
git fetch
git fetch <remote>
git fetch --pruneExamples
Download new commits from the server without changing your branches
git fetchfetch— download only, no merge
Related commands
- git pull — Download changes from the server and merge them into the current branch
- git remote — List and add remote repositories
- git merge — Bring the changes from another branch into the current one