It’s a Night When I Want to Run git reset --hard
All my commit messages are piled up like 'fix', 'real fix', 'ugh, why isn’t this working'—I just want to wipe them all out.
5 answers
Hahaha, 'real edit' is the unwritten rule... I go with 'edit2', 'edit2_real'.
If you've already pushed, git reset --hard is genuinely dangerous. If you've only piled up commits locally, you can just nuke them, but if the commits are already on the remote, it's safer to squash them with rebase -i. I once did a reset to clean up messages and got tangled up with a teammate, losing half a day. If you know git reflog, you can recover them, but even knowing that, it still makes your heart drop. Just start splitting commits into smaller units and make a message template for yourself now. If you set commit.template, it still won't make you 'edit' anything unless you enforce it with a hook lol.
Eh, I’m not so sure about that. You can clean up messy commit messages later, but blowing everything away with --hard isn’t a fix—it’s avoiding the problem, isn’t it? And the fact that things piled up like that means you never had a clear design for what you were trying to build in the first place, so even if you blow it away, the same situation is likely to happen again.
Oh, I didn't know this. I only learned the other day that you can recover it with reflog. Saving this.
I do the same... Whenever I get stuck while working, my habit of just committing first turned my log into a nightmare, but these days I make WIP commits and clean them up later with interactive rebase. It's scary at first, but once you get used to it, it's actually satisfying. I recommend getting into the habit of removing things with rebase instead of reset.