Often, when working on private branches with long histories, it so happens that a commit somewhere in between breaks the build, or some tests don’t pass anymore. If you know which commit it is you can fix it with git-rebase
. But maybe you don’t know. Maybe you aren’t even sure whether all the commits in your history build and pass the tests.
git-polish-history to the rescue!
Let’s say you are on a private feature branch with quite a few commits that you are unsure about. The last one that’s been pushed is last-pushed-commit
. To check whether your code compiles and passes all the tests you can run make check
, but you don’t want to do that manually for each commit, so let’s automate it:
git polish-history --test="make check" start last-pushed-commit
git-polish-history
will now go through all commits since last-pushed-commit
and run make check
on them. On the first one that fails it will stop and tell you to fix the problem. You can do this any way you want as long as you commit your changes. Typically you’d amend the last commit. Once you’re done, you do
git polish-history continue
and the process continues. It will stop again whenever a commit fails the test, when a merge conflict occurs, or when it’s done. If you want it to do the committing of your changes automatically, use
git polish-history continue --automatic
Here’s a video with a demonstration: