Sometimes you stuff too much into one commit and want to split it before review.
Workflow:
-
git rebase -i HEAD~3 — mark the target commit as edit.
-
When Git pauses there, undo the commit but keep the changes:
git reset HEAD^
-
Stage and commit in pieces:
git add src/auth.ts
git commit -m "feat: oauth flow"
git add src/auth.test.ts
git commit -m "test: oauth coverage"
-
git rebase --continue finishes the rebase.
Result: what was one commit is now two (or more) with surgical scope. Lets you split a "WIP" commit into reviewable atoms after the fact.
For the newest commit you don't need the rebase at all: git reset HEAD~1 moves the branch back and leaves the changes behind, then you stage and commit them in pieces. That is the version that runs in this terminal — -i needs an editor it doesn't have.