Checkpoint Commits
When working on a large feature or one that is particularly challenging, it can be helpful to save progress at known good states via “checkpoint commits”. This allows you to experiment but quickly revert back to a good state of the branch.
I ran into this recently while working on a hacky Chrome extension for a personal project. The code is not great, basically was slapped together as quickly as possible, and the goal was definitely speed, not quality. That said, part of the extension involved some tricky logic, so as I made progress I would use a “checkpoint commit” to make sure as I experimented, I didn’t lose ground that I had gained. It’s as easy as this:
git commit -m "Checkpoint"
Sure you could name these checkpoints, but I don’t even find that
necessary. As long as I have a commit so I can easily run git trash
(my
alias to clear the branch to the last commit state), I’m good to go.
This is a technique I’ve used for years, though not all that often do I find myself needing to pull it out of the toolbox. Nothing that crazy, just a quick tip I’ve found to help in certain scenarios.