Practical guide · Git

Git Fetch vs Git Pull Explained with Real Examples

Learn what each command changes, inspect incoming work before integrating it, and choose a safe update workflow for your branch.

Both git fetch and git pull contact a remote repository to retrieve changes. The important difference is what happens afterward: fetch updates your remote-tracking references without changing your current branch, while pull also integrates the fetched changes into the branch you have checked out.

Understand local and remote-tracking branches

Your local branch, such as main, is the branch you work on. A remote-tracking branch, such as origin/main, is your local record of the remote branch's latest known state. Fetching updates that record; it does not automatically move your local main branch.

Suppose both your local branches point to commit C, then a teammate pushes commit D. Before you fetch, your remote-tracking branch is still at C:

Remote server main: A --- B --- C --- D
origin/main:        A --- B --- C
main:               A --- B --- C

After git fetch origin, your view of origin/main advances to D, while main remains at C. After integrating the change, your local branch can advance too.

What does git fetch do?

Fetch downloads commits and other Git objects from a remote and updates the remote-tracking references. It leaves your checked-out branch, index, and working-tree files alone:

git status
git fetch origin
git status
git branch -r

Inspect commits on the remote that are not reachable from your current branch:

git log --oneline HEAD..origin/main

Compare the current branch with the fetched remote branch before integrating:

git diff main..origin/main

Once you have reviewed the changes, integrate them explicitly. For example, merge the fetched branch into main after switching to it:

git switch main
git merge origin/main

What does git pull do?

Pull fetches from the configured remote and then integrates the result into the current branch. In the common default setup, that integration is a fast-forward or merge. Git can also be configured to rebase, so a pull is not always exactly “fetch plus merge.”

git pull origin main

This fetches the remote's main branch and integrates it into whichever branch is currently checked out. Check git status and your current branch first so you know where the changes will go.

When you want pull to rebase your local commits on top of the fetched branch, request it explicitly:

git pull --rebase origin main

When you only want a fast-forward update and want Git to stop rather than create a merge commit if the branches have diverged, use:

git pull --ff-only origin main

Fetch and pull compared

A review-first workflow with fetch

In a shared project or before updating a critical branch, fetch first so you can see exactly what arrived:

git status
git fetch origin
git log --oneline HEAD..origin/main
git diff main..origin/main

After reviewing the commit list and file changes, choose how to integrate them. Merge when you want to preserve the branch structure, or rebase your unshared local commits when that matches your team's workflow:

git switch main
git merge origin/main

Replace main with the branch you intend to update. The commit and diff commands above compare against origin/main, so use the corresponding remote-tracking branch for your target.

When a pull creates conflicts

If your local and remote branches changed the same lines, a pull that merges may stop with a merge conflict. Git does not silently choose the right content; resolve each conflicted file, review the result, and complete the merge as Git instructs. If you are not ready to handle that integration, use fetch first and inspect the incoming work.

A rebase pull can also produce conflicts while replaying your local commits. Resolve the files and continue or abort the rebase using the commands Git reports. Do not start an integration while unrelated edits are at risk; check git status and commit or safely save your work first.

Common mistakes to avoid

Quick reference

Rule of thumb: use git fetch when you want to inspect and choose how to integrate. Use git pull when you are ready to update the current branch using your configured integration strategy.