When should I use git pull --rebase?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
git pull --rebase is useful when you want to update a branch while keeping history linear and avoiding extra merge commits from routine syncs. It fetches remote changes and reapplies your local commits on top of the updated base. This keeps commit history cleaner, but it rewrites local commit IDs, so policy and timing matter.
What Happens During Pull Rebase
A normal git pull is fetch plus merge. A rebase pull is fetch plus rebase.
Conceptually:
- Git stores your local branch commits temporarily.
- Branch pointer moves to the fetched upstream commit.
- Local commits are replayed one by one on top.
Result is a straight commit chain instead of frequent sync merge nodes.
When It Is the Right Default
Use git pull --rebase when:
- you work on personal feature branches
- team wants linear pull-request history
- you regularly sync with a fast-moving base branch
Typical workflow:
--force-with-lease is recommended after rebase because commit hashes changed. It prevents accidental overwrite of remote changes you have not fetched.
When to Avoid Pull Rebase
Avoid rebase pulls on branches shared heavily by multiple developers unless your team explicitly coordinates rewritten history.
Cases to avoid:
- shared integration branches where many people push directly
- branches where merge commits are intentionally part of audit trail
- workflows with tooling that depends on stable commit hashes
For those cases, merge pull can be safer and less disruptive.
Conflict Handling Strategy
Rebase does not remove conflicts. It changes when they appear. Conflicts are resolved per replayed commit.
If the attempt is wrong:
For long-lived branches with repeated conflict patterns, enable rerere to reuse recorded resolutions.
This can significantly reduce repetitive manual conflict work.
Local Configuration Choices
If you want rebase pull behavior by default:
Per repository:
Helpful companion setting:
Auto-stash helps when you have local uncommitted changes during pull, but still treat it as a convenience, not a replacement for intentional working-state management.
Team Policy Guidance
Consistency matters more than one universal strategy. Teams should document:
- which branches allow rebase-based history rewriting
- when force pushes are allowed
- whether merge commits are required in protected branches
- conflict-resolution expectations
Without shared policy, mixed habits cause history confusion and accidental overwrite incidents.
Practical Safety Habit
Before a rebase pull on important work, create a lightweight backup reference:
This takes seconds and gives an easy rollback anchor if conflict resolution goes wrong or if you rebase onto the wrong upstream branch. Teams that normalize this habit dramatically reduce stress around history rewriting operations.
Common Pitfalls
- Rebasing commits that collaborators already based work on.
- Forgetting to use
--force-with-leaseafter rebasing pushed commits. - Treating rebase as conflict-free by default.
- Using pull rebase on protected shared branches without team agreement.
- Running rebase pulls with unclear local state and no backup safety point.
Summary
- Use
git pull --rebaseto keep feature-branch history linear. - Prefer it for personal branches and pull-request cleanup workflows.
- Avoid it on shared branches unless team policy explicitly supports it.
- Expect conflicts and resolve them during commit replay.
- Combine with
--force-with-leaseand documented team conventions.

