back to blog

WTF is Git Rebase (and Why It’s Both Magic and Chaos)

Written by Namit Jain·July 22, 2025·3 min read

So you’ve been happily doing:

git pull
git merge

And then someone in your team says:

“Just rebase it.” …and you start questioning your life choices.


WTF Is Git Rebase, Really?

Definition (boring version): git rebase is a command that lets you rewrite the commit history by moving or combining commits onto a new base commit.

Definition (WTF version): Rebase is basically telling Git:

Yo, take my messy branch, pretend I started working from this new place, and make it look like I always had my sh*t together.


Why Even Bother?

Without rebase: Your history looks like:

main ---A---B---C
           \
            D---E (feature)

Then you merge:

main ---A---B---C------merge commit
           \           /
            D---E-----

Looks like spaghetti 🍝.

With rebase:

main ---A---B---C
                \
                 D'---E'

(Notice the '? Those are rebased commits. Same code, different timeline.)


The Actual WTF Command

Say you’re on feature branch and want it updated with main:

git checkout feature
git fetch origin
git rebase origin/main

Boom. Feature branch now looks like it was based on the latest main all along. Congratulations, you’re now a Git historian.


Common Rebase Moves

  • Interactive Rebase:
git rebase -i HEAD~3

Lets you: ✅ squash commits ✅ rename commits ✅ feel like a time-traveling wizard

  • Abort if you panic:
git rebase --abort

(You WILL need this.)

  • Continue after fixing conflicts:
git add .
git rebase --continue

This is fine meme When conflicts hit you like a truck…


When to Use Rebase vs Merge

✅ Use rebase when:

  • You want a clean history
  • You’re working on your own feature branch
  • You hate merge commits

❌ Don’t rebase shared branches (like main), or you’ll rewrite history and summon demons in your team Slack.


Pros and Cons of Rebasing

Pros:

  • Cleaner history
  • No merge commits
  • Makes you feel pro

Cons:

  • Can cause conflicts
  • Rewrite history → danger zone
  • Makes newbies(me) cry

Interactive demo

web-app - Git Rebase Simulator

Current branch: feature

Repository Branches

main
ghi789
2024-01-10
Add authentication middleware
bob1 file(s)
def456
2024-01-05
Add basic routing
alice1 file(s)
abc123
2024-01-01
Initial commit
system1 file(s)
feature
stu901
2024-01-15
Add profile tests and documentation
charlie2 file(s)
pqr678
2024-01-14
Add profile validation logic
charlie1 file(s)
mno345
2024-01-13
fix typo in profile
charlie1 file(s)
jkl012
2024-01-12
WIP: start user profile feature
charlie1 file(s)
def456
2024-01-05
Add basic routing
alice1 file(s)
abc123
2024-01-01
Initial commit
system1 file(s)
Quick start examples:
Terminal
Initialized git repository for web-app
Currently on branch: feature
$

Git Rebase Actions Guide

pick

Use the commit as-is. This is the default action.

reword

Use commit but edit the commit message.

edit

Use commit but stop for amending.

squash

Meld into previous commit and edit message.

fixup

Like squash but discard commit message.

drop

Remove the commit entirely.


TL;DR WTF

  • git merge = keep the mess
  • git rebase = rewrite history to look clean
  • Do it locally, don’t mess with shared branches
  • Always have --abort and coffee ready ☕

🔥 Next WTF Episode:

WTF is git cherry-pick (and why it ruins friendships)