📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Git & GitHub Rebasing

Rebasing

5 min read Quiz at the end
Rebase replays commits on a new base for linear history — use interactive rebase to clean commits.

Rebasing

# Rebase feature onto main (linear history)
git switch feature/login
git rebase main

# Interactive rebase — edit, squash, reorder commits
git rebase -i HEAD~3       # last 3 commits
# Commands in editor:
# pick   — keep commit
# squash — combine with previous
# reword — edit commit message
# drop   — remove commit
# fixup  — squash, discard message

# Rebase --onto
git rebase --onto main serverfix feature

# Abort rebase
git rebase --abort

# Continue after resolving conflict
git rebase --continue
Topic Quiz · 1 questions

Test your understanding before moving on

1. What does git rebase -i HEAD~3 let you do?
💡 Interactive rebase opens an editor where you can pick, squash, reword, or drop commits.