Skip to main content

Sign in

Save your progress and access it from any device.

Or with email

Don't have an account?

Privacy policy

Git pull: retrieve remote changes

Your team pushed code? git pull downloads and merges remote changes into your local branch. It is the daily command for team collaboration.

Essential

What is git pull?

git pull is the combination of two commands: git fetch (download) and git merge (merge). In a single command, you retrieve and integrate your team's work.

Think of a mailbox: git fetch is checking if there's mail. git pull is checking and reading the mail right away.

Git pull syntax

git pull

Pull from the tracked branch

git pull origin main

Explicit pull from origin/main

git pull --rebase origin main

Pull with rebase for a linear history

Git pull in practice

Standard pull and pull with rebase.

Standard pull

Pull with rebase

git pull vs git fetch

git pull

Downloads remote changes and merges them into your local branch automatically.

Use when: you trust the remote changes

git fetch

Downloads remote changes without merging them. You can inspect before deciding.

Use when: you want to inspect before merging

Common mistakes with git pull

Pulling on the wrong branch

Check your current branch with git branch before pulling. Pulling on main while you are on your feature branch can create unexpected conflicts.

Unresolved conflicts

If a pull generates conflicts, Git waits for you to resolve them. Open the conflicted files, run git add then git commit. Or cancel with git merge --abort.

Uncommitted local changes

Git refuses to pull if you have uncommitted changes. Run git commit or git stash before pulling.

Part of the Git Remote & Collaboration guide

A

GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.

Questions about git pull

Master teamwork with GitQuest

GitQuest investigations simulate collaborative work: pull, push, conflicts, and resolutions.

Start the investigations