Typorithm · hard

rebase

git-rebasegitrebaseinteractivehistory
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn rebase

0%

Branching

git rebase replays your commits on top of another base for a linear history. It rewrites commit hashes, so never rebase shared or pushed history. --continue resumes after a conflict and --abort restores the original; interactive (-i) lets you squash, reorder, or edit the last N commits.

After git switch feature, git rebase main lifts your branch's commits and re-applies them one by one on top of main's tip, producing a clean linear history instead of a merge commit.

Because each commit is replayed, rebase rewrites their hashes — that is why you must never rebase history others have already pulled or that you have pushed. If a replay conflicts, fix the files and run git rebase --continue; git rebase --abort restores the branch exactly as it was.

Interactive rebase, git rebase -i HEAD~3, opens an editor listing the last three commits so you can squash them together, reorder them, or edit individual commits before they are rewritten.

01

rebase replays commits onto a new base for linear history.

02

It rewrites hashes — never rebase shared or pushed history.

03

-i lets you squash, reorder, or edit the last N commits.

git switch feature
git rebase main
git rebase --continue
git rebase --abort
git rebase -i HEAD~3

Read the implementation

Connect each part of the code to the concept before you type.

1. Go to your branch

Rebase replays the current branch, so switch to feature first.

git switch feature

2. Replay onto base

git rebase main re-applies feature's commits on top of main for a linear history.

git rebase main

3. Resume

--continue proceeds with the rebase after you have resolved a conflict.

git rebase --continue

4. Restore original

--abort stops the rebase and returns the branch to its original commits.

git rebase --abort

5. Interactive rebase

-i opens an editor to squash, reorder, or edit the last three commits.

git rebase -i HEAD~3

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

rebase: Lesson & Practice · Typorithm | ApplyDjinn