Ubuntu - GIT - git bisect

This command is great when you want to find out which commit introduced a breaking change.

bisect performs a binary search to help you pinpoint which commit is bad.

All you have to do is tell it which commit was bad, a commit that's good, and it'll automatically checkout the commits in between and have you test them.

Once you're finished git bisect reset.

git init
Initialized empty Git repository in /home/john/Projects/git-bisect-test/.git/
 
echo "bacon" > bacon.txt
git add bacon.txt
git commit -am "add bacon file"
[master (root-commit) 0113afa] add bacon file
 1 file changed, 1 insertion(+)
 create mode 100644 bacon.txt
 
echo "cheese" > cheese.txt
git add cheese.txt
git commit -am "add cheese"
[master (root-commit) db5019e] add cheese
 1 file changed, 1 insertion(+)
 create mode 100644 cheese.txt
 
ls
bacon.txt cheese.txt
 
echo "introduce bug" >> bacon.txt
git commit -am "introduce bug"
[master (root-commit) c7a5fa2] introduce bug
 1 file changed, 1 insertion(+)
 
git log --oneline 
c7a5fa2 introduce bug
db5019e add cheese
0113afa add bacon file
 
git bisect start
git bisect bad
git bisect good 0113
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[db5019e38614ef383cb89095891cb968d3662168] add cheese
 
git bisect good
c7a5fa2aea65d90d40a97807005b62c29fa7b2f4 is the first bad commit
commit c7a5fa2aea65d90d40a97807005b62c29fa7b2f4
Author John Smith <john.smith@gmail.com>
Date:  Wed Jul 22 11:08:54 2015 -0700
 
    introduce bug
 
:100644 100644 63953b20236748b0e581a68b6f5b26458c006d9d 988aa7edb7f8848c3853f3561148a8832e8f2907 M           bacon.txt
 
git bisect reset
Previous HEAD position was db5019e... add cheese
Switched to branch 'master'