4 ms·
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 uncommi
by svyatoslavpavl 2mo 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.
- bonzini 2mo agoOr 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.
- svyatoslavpavl 2mo agohadn'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
- wasting_time 2mo agoPlease don't use LLM to write HN comments. To quote the guidelines[0], "HN is for conversation between humans". [0] https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html