Bisect
Git Bisect is a tool that helps you automatically find the commit that introduced a bug or issue in your
codebase.
It works by using a binary search algorithm to efficiently narrow down the problematic commit. Git Bisect
requires you to provide
the hash of a good commit and a bad commit- ie. An example of when your code was working and another example
of when it was not.
How Bisect Moves Through History

The power of bisecting means that if there were 1000 commits between a good state and bad
the most commits you would need to review when using bisect is 10.
How to Bisect:
- Locate the commit hash of a good state and abad state. If your good state is the same as the HEAD then you do not need to provide a git hash in this instance because if no hash is provided HEAD will be assumed.
- Start the git bisect process
- When prompted provide a good state and a bad state.
- You will be prompted to confirm if a commit is good or bad. Git bisect will then bisect the remaining commits again.
- Once the bad commit is located return to the HEAD and address the issue as desired
Use Cases:
- Locating a bug
- Find the commit that broke a feature
- Finding a Commit that changed functionality
Examples:
List Commits to identify good and bad state:
git log --oneline
Start bisecting:
git bisect start
     OR
git bisect start [bad-commit-hash] [good-commit-hash]
Adivse starting good state:
git bisect good [good-commit-hash]
Adivse starting bad state:
git bisect bad [bad-commit-hash]
     OR
If bad state is on the HEAD no commit hash is needed
git bisect bad
Confirm if provided commit is good:
git bisect good
Confirm if provided commit is bad:
git bisect bad
Return to Head:
git bisect
Provide different terms:
git bisect old
Provide different terms:
git bisect new
Confirm current terms:
git bisect terms
Log bisect file:
git bisect log > bisect.txt