Git Cheat Sheet · Synchronize

Get new commits without integrating them

git fetch

git fetch downloads the remote's new commits and branches, without changing your branch or your files. You can then look at what changed, and decide whether to integrate it with a merge or a rebase.

What it does

Downloads the commits and branches of the remote without changing your branch or your files.

A use case

You want to see what the team pushed before deciding whether to integrate it.

On the command line

git fetch
Gets new commits from the current branch's remote, usually origin.
git fetch --all
Queries all remotes.
git fetch --prune
Also forgets branches deleted on the remote.
git log HEAD..origin/main
Lists fetched commits that you do not have yet.

In Merathon

  1. "Fetch" button in the toolbar.
  2. Right-click a remote in "Remote" → "Fetch <remote>" to query only that one.
  3. The counters next to the branches then show how far ahead and behind they are.

Frequently asked questions

What is the difference between git fetch and git pull?

git fetch only downloads. git pull does a fetch, then immediately integrates the commits into your branch, with a merge or a rebase.

Can git fetch lose my work?

No. It changes neither your local branches nor your working copy.

See also