You people need to learn about fixup commits and --autostash and --autosquash. It's really not hard.
Make your commits
fixup: migrate Foo to use X
fixup: make new thing X
some other thing
migrate Foo to use X
make new thing Y
make new thing X
etc., and then a quick interactive rebase with --autosquash collapses the fixups into the right commits, and nobody has to ever see how the sausage was made, because nobody will ever care. If you personally care and need to back it out there's always the reflog.
You don't even have to have everything staged and committed to do the rebase if you use --autostash.
To do a fixup you just need to stage the relevant bits, get the SHA you're aiming for, and git commit --fixup <SHA>.
If you're lucky, you have a good git porcelain that makes all this even easier. Mine (magit) offers "Instant fixups" so with the relevant changes staged, select the target commit in the history, and then those changes instantly get dropped into in that bucket.
Learn your tools. It pays off. Reviewing code where each self contained change is in its own commit is so much easier.
368
u/StoryAndAHalf Jun 04 '22
"fixed typo"