last_updated: 2026-03-25

Git Bisect Cheatsheet#

Given that HEAD is a bad commit and v2.6.13-rc2 is good, start the bisect process:

git bisect start
git bisect bad
git bisect good v2.6.13-rc2

Next, choose either one of:

git bisect good
git bisect bad
git bisect skip

When done:

git bisect reset

Commits That Cannot be Tested#

Git’s bisect is one of the reasons, why you should commit working code only. If you have commits that cannot be tested, you may skip them with

git bisect skip

Automation#

Create a script that runs your tests and returns an error code that git bisect can use: 0 for success or 1..127 (inclusive) for errors, e.g.

cat <<EOF > /tmp/bisect-run.sh
#!/bin/bash
set -euo pipefail

docker-compose down --remove-orphans
docker-compose up -d --build --remove-orphans --wait
pytest
EOF

chmod +x /tmp/bisect-run.sh

Use it for bisect

git bisect run /tmp/bisect-run.sh

Further Reading#

https://git-scm.com/docs/git-bisect