Git Cheat Sheet · Synchronize
Integrate new commits from the remote
git pull · git pull --rebase
git pull gets the remote's commits and integrates them into your branch. If there are only remote updates, the branch simply moves forward. If you also have local commits, Git makes a merge, or a rebase with git pull --rebase.
What it does
Gets the remote commits and integrates them into the current branch, by merge or by rebase.
A use case
A colleague pushed to the same branch as you: you update before continuing.
On the command line
git pull- Fetch then integration, according to your configuration.
git pull --rebase- Replays your local commits on top of the remote's: linear history.
git pull --ff-only- Only accepts a fast-forward, and stops if the branches have diverged.
git config --global pull.rebase true- Makes
--rebasethe default behavior.
In Merathon
- "Pull" button: fast-forward if possible, otherwise merge.
- The small arrow next to it ("Pull options") offers "Pull (rebase)", which replays your commits on top of the remote's and keeps a linear history.
- Right-click another local branch → "Pull" updates it without switching to it.
Frequently asked questions
What does "You have divergent branches" mean?
You and the remote each have commits the other does not. Choose a strategy: git pull --rebase or git pull --no-rebase (merge).
How do I undo a git pull?
Right after it, git reset --hard ORIG_HEAD puts the branch back where it was. Be careful, uncommitted changes are lost.