bashadvanced
Git Bisect to Find a Bug
Use binary search through commit history with git bisect to find the exact commit that introduced a bug.
bashPress ⌘/Ctrl + Shift + C to copy
# Start bisect session
git bisect start
# Mark current commit as bad (has the bug)
git bisect bad
# Mark a known good commit (before the bug)
git bisect good v1.0.0
# or by hash:
git bisect good abc1234
# Git checks out a middle commit — test it
# If this commit has the bug:
git bisect bad
# If this commit works fine:
git bisect good
# Repeat until Git finds the culprit:
# "abc1234 is the first bad commit"
# End the bisect session
git bisect reset
# Automated bisect with a test script
git bisect start HEAD v1.0.0
git bisect run npm test
# Automated bisect with custom script
git bisect run bash -c 'node -e "require(\"./dist/app\")" 2>/dev/null'
# View bisect log
git bisect log
# Skip a commit that can't be tested
git bisect skipUse Cases
- Finding which commit introduced a regression
- Automated bug hunting across hundreds of commits
- Debugging intermittent failures in CI
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashintermediate
Git Bisect — Find the Commit That Broke It
Use binary search across commits to pinpoint exactly which commit introduced a bug or regression.
Best for: Finding which commit introduced a regression
#git#bisect
bashintermediate
Git Blame Investigation Techniques
Use git blame and related tools to trace code authorship and understand change history.
Best for: Finding who introduced a bug
#git#blame
bashintermediate
Git Hooks Pre Commit
Git workflow: git-hooks-pre-commit
Best for: version control
#git#version-control
bashadvanced
Git Hooks Post Commit
Git workflow: git-hooks-post-commit
Best for: version control
#git#version-control