|
|
Log in / Subscribe / Register

splitting git commits

splitting git commits

Posted Feb 12, 2026 14:11 UTC (Thu) by iabervon (subscriber, #722)
In reply to: splitting git commits by AdamW
Parent article: Evolving Git for the next decade

That is... a... way. I'm not sure there is a right way, though, just different ways that different people do use successfully. My personal method is actually for taking a branch that has a bunch of commits with mistakes I fix later, accidental whitespace changes, parts of false starts, etc. and making a clean branch where each commit does things I can describe and justify and eventually reaches almost the same tree.

git checkout origin -b refine
git diff HEAD messy | git apply
(edit, sometimes)
git add -p (say yes to what you want to do in this step)
git checkout .
make check
git commit
(repeat)

There are some snags around handling new files that "messy" added, but it's otherwise a pretty nice workflow (and fewer than seven git commands?). On the other hand, I've never taught someone else to do it, so I don't know how easy it is to learn.


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds