14 March 2024
Splitting a Git commit into multiple commits
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.
Reset to
HEAD~1
to undo the commitgit add -p
to create the new commitsCommit as normal
git rebase --continue
to go to the next commit to split, or finish.