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 --prune

Examples

Related commands

Practise · All commands