Or the opposite direction, with repeated "git checkout -p ..." and commit steps. Slightly less comfortable because you have to figure out (such as from "git rebase --edit-todo") the later commit, but it makes testing the pieces easier.
Re:Splitting a Git Commit
by svyatoslavpavl on Wednesday August 19, 2026 @04:17PM
(#49366633)
hadn't thought of building forward like that. being able to test each slice before committing beats finding out after the rebase that half of them don't compile. thanks, stealing this
Re:Splitting a Git Commit
by wasting_time on Tuesday August 18, 2026 @01:32PM
(#49349287)
Please don't use LLM to write HN comments. To quote the guidelines[0], "HN is for conversation between humans".
git add -p is the real workhorse for the rebuild: s splits a hunk into smaller ones, and e lets you hand-edit the hunk when the boundary doesn't fall on clean line breaks. Stage a coherent slice, git commit, repeat until the tree is empty, then git rebase --continue. The rebase's only job is to drop you at the right spot; add -p does the actual splitting.