Rebase Helper
Git rebase guide online. Interactive rebase steps with visual explanation. Learn rebase commands—free Git rebase tool.
Interactive Rebase
⌨️ Command
git rebase -i HEAD~3📋 Interactive Rebase Actions
pick (p)Use commit as-is
reword (r)Use commit, but edit message
edit (e)Use commit, but stop for amending
squash (s)Meld into previous commit, edit message
fixup (f)Meld into previous commit, discard message
drop (d)Remove commit entirely
📝 Example Todo List
pick a1b2c3d feat: add user authentication pick b2c3d4e fix: resolve login bug pick c3d4e5f docs: update API documentation
Change pick to any action above, then save and close.
📚 Step-by-Step Guide
1
Start Interactive Rebase
git rebase -i HEAD~3 Opens editor with last 3 commits
2
Edit the Todo List
# Change "pick" to desired action Modify actions for each commit
3
Save and Close
:wq (vim) or Ctrl+S, Ctrl+W (VS Code) Git processes your changes
4
Resolve Conflicts
git add . && git rebase --continue If any conflicts arise
5
Complete or Abort
git rebase --continue OR git rebase --abort Finish or cancel the rebase
💡 Common Scenarios
📦 Squash Last 3 Commits
- git rebase -i HEAD~3
- Change 2nd and 3rd line to "squash" or "s"
- Save and edit combined commit message
✏️ Reword a Commit Message
- git rebase -i HEAD~n (where n includes your commit)
- Change "pick" to "reword" for target commit
- Edit the message when prompted
🗑️ Remove a Commit
- git rebase -i HEAD~n
- Change "pick" to "drop" or delete the line
- Save and let rebase complete
🔀 Reorder Commits
- git rebase -i HEAD~n
- Rearrange the lines in desired order
- Save (may need to resolve conflicts)
🌿 Before vs After Rebase
Before
After Rebase
⚠️ Important Warnings
- • Never rebase commits that have been pushed to shared branches
- • Use
git rebase --abortif something goes wrong - • Create a backup branch before rebasing:
git branch backup - • Force push is required after rebasing:
git push --force-with-lease
Features
- Interactive guide to interactive rebase (`-i`)
- Visual explanation of squash, fixup, reword, drop
- Command generator for common rebase scenarios
- Conflict resolution tips
Common Use Cases
- Cleaning up local commit history before merging
- Updating a feature branch with latest main text
- Squashing "wip" commits
Git Rebase
Rebasing is the process of moving or combining a sequence of commits to a new base commit. Interactive rebase (`git rebase -i`) is a powerful tool to rewrite history by editing, reordering, or merging commits.
Examples
Valid - Interactive Rebase
git rebase -i HEAD~3 Valid - Rebase on main
git checkout feature
git rebase mainFrequently Asked Questions
Rebase vs Merge?
Merge preserves history exactly as it happened. Rebase creates a linear, clean history but rewrites commit hashes.
Is it safe?
Only rebase branches that *only you* are working on. Never rebase public/shared branches.
💡 Tips
- Use `fixup` during rebase to merge a commit into the previous one without keeping its log message.