Rebasing
Part of the Git course
You branched off main on Monday to add a search box. It is now Thursday, you have three commits, and in the meantime four other people have pushed to main. Your branch is built on a version of the project that no longer exists anywhere. Before your work can join main, those two lines of history have to be brought back together, and Git gives you two different ways to do it.
The first is a merge, which records the truth: two lines of work existed side by side, and here is the commit where they came together. The second is a rebase, which rewrites your side of the story so it looks like you started your work this morning, from the current tip of main. Merge is honest about what happened. Rebase is tidy about what it leaves behind.
Want to learn Git Rebasing in a real environment?
Click below, get a fresh Linux box with Git ready to go, and work through Rebasing hands-on with an AI tutor that knows your code.
Start this lessonRebasingWhat you'll learn
- Git rebase
- Replay on top
- Linear history
- When not to rebase
Read this lesson in your language
All lessons in this course
13 lessons- 1Init and Your First Commit25 min
- 2Status, Diff, and Log25 min
- 3Branches and Merging30 min
- 4Resolving Merge Conflicts30 min
- 5Remotes: Push, Pull, Fetch30 min
- 6Stash and Cherry-pick25 min
- 7Rebasing30 min
- 8Interactive Rebase and Squashing30 min
- 9Tags and Releases20 min
- 10Branching Workflows20 min
- 11Recovering Lost Work25 min
- 12Hooks25 min
- 13Capstone: A Full Pull Request Flow40 min
