Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
The “rebase vs merge” debate is one of the most discussed topics in Git. This is because Git provides two different ways to integrate changes, and the choice often comes down to preference.
The Short Answer
Use both—they serve different purposes.
How Rebase Works
When working on a feature branch, and you’re ready to merge it into main, you rebase the feature branch upon main.
This means:
- All changes committed to
mainare applied to your feature branch first - Then all your feature branch commits are applied after them
Even if work continued on main after you created your feature branch, after rebasing it will look like all the main commits were done before you even created your branch.
The Workflow
- Create a feature branch from
main - Make your commits on the feature branch
- Meanwhile,
mainmight receive new commits - Before merging, rebase your feature branch upon
main:
git checkout feature-branch
git rebase main
- Resolve any conflicts during the rebase
- Once ready (and assuming no new changes to
main), merge with a fast-forward:
git checkout main
git merge feature-branch
Benefits of This Approach
Avoiding Merge Commits
When you rebase before merging, you can do a “fast-forward merge” which doesn’t create a merge commit. Merge commits can clutter your history with messages like “Merge branch ‘feature’ into main”.
Cleaner History
Your git log shows a linear history without interleaved commits from different branches. It’s easier to understand what happened and when.
Easier Conflict Resolution
By resolving conflicts during rebase (one commit at a time), you often get smaller, more manageable conflicts than resolving everything at once during a merge.
The Golden Rule
Never rebase main (or any shared branch).
Rebasing rewrites history. If you rebase main, you’re rewriting the history that other developers have based their work on. This leads to divergent histories and painful merge conflicts.
Only rebase feature branches upon main—never the other way around.
When to Just Use Merge
Sometimes a simple merge is fine:
- Quick fixes directly on
main - When you want to preserve the exact history of when things happened
- When working with less experienced team members who might find rebase confusing
Summary
- Work on feature branches
- Rebase feature branches upon
mainbefore merging - Fast-forward merge to avoid merge commits
- Never rebase shared branches like
main