The bisect
command is good when you don't know where in your code there is a bug, but you can test for it and thereby find the commit that introduced it. If you already know where in the code the bug is but want to find the commit that introduced it, you can use git blame
. The blame
command will annotate every line in the file with the commit that most recently touched that line, making it easy to find the commit ID and then the full context of the commit.
We'll use the same repository and branch as in the bisect example:
$ git clone https://github.com/PacktPublishing/Git-Version-Control-Cookbook-Second-Edition_tips_and_tricks.git $ cd Git-Version-Control-Cookbook-Second-Edition_tips_and_tricks $ git checkout bug_hunting