Skip to Content

Git - Debuging with git bisect

Posted on

git-bisect - Use binary search to find the commit that introduced a bug

We will use git bisect <subcommand> <options> to find the commit that make our code wrong.

The idea of this command is that:

  • We start with current version (1) - which contains the error.
  • Mark a old version (2) - which everything works fine.
  • Use binary search to get middle commit between (1) and (2), check this commit to detect it is bad or good
  • Repeat


git bisect start

# Mark current version is bad (wrong)
git bisect bad

# Mark a commit/version is good (our code is ok)
git bisect good <goodcommit>

And repeat above process. If issue still exists?

  • Yes: git bisect bad
  • No: git bisect good


<abcdef> is the first bad commit


comments powered by Disqus