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.
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 pullPull from the tracked branch
git pull origin mainExplicit pull from origin/main
git pull --rebase origin mainPull 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.
git fetch
Downloads remote changes without merging them. You can inspect before deciding.
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
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