Gitflow
✂️Split One Commit Into TwoHard+700 XP
Workshop
Scenario reference

Split One Commit Into Two: the situation, step by step

The situation

You bundled an unrelated CSS tweak into your big API refactor commit. Reviewer asks: 'Please separate these.'

Interactive rebase, mark `edit`, reset HEAD~ to unstage, then add + commit twice.

Hard · 5 steps · +700 XP

What you will practice

This scenario walks through 5 steps, in order:

  1. 01Interactive rebase, mark the commit `edit`
  2. 02Unstage everything to the working tree
  3. 03Stage and commit the refactor
  4. 04Stage and commit the CSS
  5. 05Finish the rebase
Reveal the step-by-step commands

Try the terminal first — you learn more by doing. When you want to check yourself, here is the command for each step.

  1. 1. Interactive rebase, mark the commit `edit`
    git rebase -i HEAD~1
  2. 2. Unstage everything to the working tree
    git reset HEAD^
  3. 3. Stage and commit the refactor
    git commit -m "refactor: api"
  4. 4. Stage and commit the CSS
    git commit -m "style: button tweak"
  5. 5. Finish the rebase
    git rebase --continue

Key takeaway

edit → reset HEAD^ → add -p → commit → commit → rebase --continue.