Rebase
Reapplying commits on top of another base commit to create a linear history in version control.
Also known as: Git Rebase, Interactive Rebase
Category: Concepts
Tags: software, version-control, workflows, git, best-practices
Explanation
Rebasing is a Git operation that moves or combines a sequence of commits to a new base commit. Instead of creating a merge commit like merge does, rebase rewrites commit history by replaying your changes on top of another branch, creating a linear progression.
When you rebase, Git finds the common ancestor of your branch and the target branch, takes all your commits since that point, and reapplies them one by one onto the target branch. This results in a clean, linear history without merge commits. Each commit gets a new SHA hash because its parent has changed, effectively rewriting history.
Rebase is powerful for cleaning up work before sharing it. Interactive rebase (`git rebase -i`) lets you edit, reorder, squash (combine), or drop commits, creating a polished narrative of changes. This turns messy development history into a clear story that's easy for others to understand and review.
The golden rule: never rebase commits that have been pushed to a public repository and that others might have based work on. Rewriting shared history causes conflicts for collaborators. Use rebase for local cleanup before pushing, but use merge for integrating shared work.
In knowledge work, rebasing represents revision—rewriting ideas with a clearer structure, reorganizing thoughts into a more logical flow, or presenting conclusions without showing every wrong turn. It's the difference between showing your thinking process versus presenting refined insights.
Related Concepts
← Back to all concepts