This is a very contrived way to show off what git-bisect is good for.
This will create a file called test_file
and then do a bunch of commits with one "bad" one randomly inserted somewhere in the middle. And the "bad" commit involves a deletion, so you can't find it using a simple git blame
on the file.
./generate_commits.rb
git bisect bad
git bisect good $(git log --oneline | grep "starting state" | cut -d ' ' -f 1)
grep teapot test_file
git bisect [good|bad]
grep teapot test_file
git bisect [good|bad]
...
And based on the result of grep teapot test_file
, mark the commit as good or bad until you find the right commit.
You can also just do git bisect run grep teapot test_file
and it'll go much more quickly and automatically.
This example has been contrived to make it impossible to use git blame
instead of needing to bisect, but it still doesn't require a bisect. You can just do git log -p -G teapot
instead. I know this. I just made this to show off how bisect works, and didn't put in the extra work to show where you need to bisect.