Skip to main content
⚡ OpenDevDocs
Git
gitgitGuideBeginner

git pull — Fetching and Merging Remote Updates

How git pull works: git fetch + git merge combination, rebase pulls (git pull --rebase), fast-forward only, and preventing unwanted merge commits.

Verified: 2026-09-30
Platforms:
all
#git#pull#fetch#rebase#remotes

git pull — Fetching and Merging Remote Updates

The git pull command is shorthand for two consecutive actions:

  1. git fetch (download new commits from remote)
  2. git merge (or git rebase) to integrate them into your current local branch.
git pull = git fetch + git merge (or git rebase)

1. Syntax and Basic Usage

# Pull changes from default upstream remote branch:
git pull

# Explicitly pull from remote branch:
git pull origin main

2. Rebase Pull (git pull --rebase) — Best Practice

By default, running git pull when local and remote branches have diverged generates a messy 3-way merge commit ("Merge branch 'main' of github.com...").

Using --rebase keeps your local commit history completely clean and linear by replaying your local commits on top of incoming remote updates:

git pull --rebase origin main

Configure Rebase as Global Default:

git config --global pull.rebase true

3. Fast-Forward Only Pull (--ff-only)

If you want git pull to fail immediately rather than creating an unexpected merge commit when history diverges:

git pull --ff-only origin main

On this page