Rebase in Git
Task
Create diverging changes in main and bugFix, then move the work from bugFix on top of the up-to-date main using rebase.
Steps
- Create the
bugFixbranch and make one commit in it. - Go back to
mainand make one separate commit. - Switch back to
bugFix. - Rebase the
bugFixbranch ontomain.
Expected result
The commit from bugFix must be copied on top of the tip of main. The history becomes linear, no merge commit should appear, and HEAD stays on bugFix.
What you will learn
After completing the task, you will be able to:
- tell rebase apart from merge;
- move commits onto a new base;
- understand why a commit gets a new identifier after a rebase.
Goal
local