Skip to main content
Back to command reference
Remote Repositories

git fetch

Download remote data without changing your working directory

Practical example

bash
git fetch origin                  # fetch all branches from origin
git fetch --prune                # fetch and remove stale remote refs
# Then: git log origin/main to see what was fetched

Command overview & how it works

Downloads commits, branches, and tags from a remote repository but does not modify your working directory or current branch. This makes it safer than git pull — you can review changes before integrating them. After fetching, you can inspect the remote branches with git log origin/main, diff with git diff main origin/main, or merge with git merge origin/main. Use git fetch --all to fetch from all configured remotes at once. Use git fetch --prune to remove local references to remote branches that no longer exist on the remote. Use git fetch origin to fetch all branches from origin, or git fetch origin main to fetch only the main branch. Fetching is the safest first step before deciding how to integrate remote changes.

Chapter 05 · Remotes & Collaboration

Master upstream tracking, SSH auth, and team workflows

Upstream sync strategies, merge vs rebase on pull, and semantic release tagging in the 97-page course — ₹499.

Learn more

Practical tips

  • Fetch before you pull to review what changed first: git fetch origin, then git log origin/main.
  • Use git fetch --prune to drop local references to remote branches that no longer exist on the remote.
  • Fetching never touches your working tree — it is the safe way to see what your collaborators have pushed.

Deep-dive guides & tutorials

In-depth walkthroughs and practical scenarios related to git fetch

All guides →

Related commands

More from Remote Repositories