CurriculumRemote Repositoriesgit pull — Downloading Changes
Lesson 4 of 757%
Intermediate7 min+70 XP

git pull — Downloading Changes

git pull downloads changes from the remote AND immediately merges them into your current branch. It is a convenience shortcut combining git fetch (download) followed by git merge (integrate) into a single command.

01.What Pull Does in Two Phases

Phase 1 (fetch): downloads all new commits from the remote and updates the remote-tracking references like origin/main — your local branches are untouched. Phase 2 (merge): merges origin/main into your current local branch. This can produce merge commits or conflicts, just like any merge.

Distributed Architecture
💻
Your Local
push / pull
☁️
GitHub (Remote)
push / pull
💻
Teammate's Local

02.git pull --rebase (Recommended)

Instead of creating a merge commit, --rebase replays your local commits on top of the updated remote branch. Result: clean linear history with no merge commits. Many teams configure this as the default. Great rule of thumb: pull --rebase on feature branches, regular pull on main.

Commit Timeline
a1b2c3d
init
b2c3d4e
feat
c3d4e5f
fix
d4e5f6a
HEAD

Commands

commands — click to reveal output
$
git pull
Pull from the tracked upstream branch
▼ show output
$
git pull origin main
Explicitly pull from origin main
$
git pull --rebase
Pull and rebase instead of merge (cleaner linear history)
$
git pull --rebase origin main
Rebase against a specific remote branch
$
git config --global pull.rebase true
Set --rebase as the default behavior for all pulls
KNOWLEDGE CHECK

git pull is equivalent to which two commands run in sequence?

Rate this lesson:
PreviousNext Lesson