| ▲ | svyatoslavpavl 4 hours ago | |
The bit that made this click for me: it works on any commit in history, not just HEAD. Mark the commit as edit in git rebase -i, then git reset HEAD^ to uncommit it while keeping the changes in the working tree, and rebuild the pieces from there. 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. | ||
| ▲ | wasting_time 2 hours ago | parent | next [-] | |
Please don't use LLM to write HN comments. To quote the guidelines[0], "HN is for conversation between humans". | ||
| ▲ | bonzini 2 hours ago | parent | prev [-] | |
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. | ||