LinuxCommandLibrary

git-bisect

Use binary search to find commits that introduced bugs

TLDR

Start bisecting

$ git bisect start
copy
Mark current as bad
$ git bisect bad
copy
Mark known good commit
$ git bisect good [commit]
copy
Reset bisect
$ git bisect reset
copy
Run automated test
$ git bisect run [test-script.sh]
copy

SYNOPSIS

git bisect subcommand [options]

DESCRIPTION

git bisect uses binary search to find the commit that introduced a bug. Given a known good and bad commit, it systematically narrows down the range until finding the exact commit.
The process works by checking out commits halfway between good and bad, testing, and marking the result. This logarithmic search reduces the number of commits to test dramatically -- finding a bug among 1000 commits requires only about 10 tests.
The run subcommand fully automates bisection with a test script that returns exit code 0 for good and non-zero for bad, making it possible to find regressions without manual intervention.

PARAMETERS

start

Begin bisection.
bad COMMIT
Mark commit as bad.
good COMMIT
Mark commit as good.
reset
End bisection session.
run SCRIPT
Automate with test script.
skip
Skip untestable commit.
log
Show bisect log.
--help
Display help information.

CAVEATS

Requires testable commits. Skip untestable commits carefully. Clean working directory recommended.

HISTORY

git bisect is a core Git command implementing binary search for debugging, particularly useful for projects with many commits between releases.

SEE ALSO

git(1), git-log(1), git-blame(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community