Git Bisect project with Git Submodules

The standard git bisect command help to quickly identify the specific commit that introduced a bug in a Git repository. In projects where branches with lots of commits were previously merged, there may be known-bad commits with build failure unrelated to the current bisect search. It’s possible to skip such commits during the bisect process, or avoid specific commits altogether.

For projects using Git Submodules, an additional command

git submodule update --init --recursive

at each step of the bisect process is required to update the submodules to the correct commit. One can make a simple shell script to use with git bisect run to automate this process, or simply run the command manually after each bisect step.

git bisect start
git bisect <good|bad> <commit>
git submodule update --init --recursive
git bisect run <test command>
git submodule update --init --recursive
# ... repeat as necessary ...
git bisect reset