Git bisect run techniques

submited by
Style Pass
2024-09-05 03:00:04

git bisect run lets us find the breaking commit in O(log(N)) time for N commits, by doing a binary search through commits to determine the one which broke things. It is extremely useful, but the thing which often takes a long time is figuring out which command to use to reliably determine whether a commit is good or bad. This article explains some techniques to help with this task.1

Put anything but the most trivial command in a script file, for easier reading and writing. This way we won’t need to deal with an extra layer of complexity and bugs. A quick template:

grep --quiet is probably the simplest way to search through standard output of a command for a value. But for maximum debugging potential we probably want to print the original output of the command as-is (slightly modified for readability):

To search through standard error instead of standard output, we need to swap standard error and standard output at the start and end of the pipeline, while telling tee to use another file descriptor for the copy of standard output3:

Leave a Comment