I am already accustomed to hidden gems in Git. Still, finding one is always nice. Recently, I was reading through git-rebase
manpage, and two things drew my attention. The fact that one of the examples uses deadbee
and fa1afe1
as commit hashes is of course funny, but not that important. What is much more interesting, however, is a feature I’ve never heard of before. Among various “actions” you can perform on commits during git rebase --interactive
(you know, pick
, edit
, squash
etc.), there is one which is different than others in that it is not associated with a commit, but may come between commits. You can say e.g. exec make
, and when Git gets to this point during rebasing, it will execute make
(or whatever command you want, say npm test
). If this command exits with non-zero status (which means some kind of failure), Git will stop so that you can fix the problem. This way you can make sure that every commit on master
compiles correctly (or even passes the tests). (See the manpage for details.) Very handy!