I signed the Hope Accord.
14 March 2024

Splitting a Git commit into multiple commits

To split a commit into multiple commits I’ve used the following workflow:

  • Do an interactive rebase from an earlier commit.

  • Change the command for the commit(s) to split to edit.

  • When you run the rebase, you’ll be dropped back into the shell for each commit, at that commit (after the commit has been applied).

  • Reset to HEAD~1 to undo the commit.

  • git add -p to create the new commits.

  • Commit as normal.

  • git rebase --continue to continue the interactive rebase. If there are no more interactive actions to do, you’re done.

See https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#_splitting_a_commit.