1

I know that the tip of topic-branch-7 has a bug, and I know that the tip of master does not have the bug. I'd like to find out where the bug was introduced in topic-branch-7. So I've run the following:

git checkout topic-branch-7
# some testing to verify the bug
git bisect start bad  # start a git bisect and mark this commit as bad
git-merge-base master topic-branch-7
9ac8c59bb10c13d86bcdeff90cb47e25d477caad
git checkout 9ac8c59bb10c13d86bcdeff90cb47e25d477caad
# some testing to verify the bug is not present
git bisect good

What's throwing me is that when I run git bisect good ... nothing happens! Isn't it supposed to mark the commit as good, find a midpoint between this commit and the bad commit, and do a checkout to that commit? Why is nothing happening?

skiphoppy
  • 97,646
  • 72
  • 174
  • 218

2 Answers2

2

I think you have the syntax for git bisect wrong. It should be

git-merge-base master topic-branch-7
9ac8c59bb10c13d86bcdeff90cb47e25d477caad
git bisect start topic-branch-7 9ac8c59bb10c13d86bcdeff90cb47e25d477caad
#you are now at a commit somewhere in between topic-branch-7 and 9ac8c59bb10c13d86bcdeff90cb47e25d477caad
#do testing to find out if bug is there
git bisect good/bad
#repeat until git tells you where the bug is introduced
git bisect reset HEAD
Drew
  • 12,578
  • 11
  • 58
  • 98
0

I know git bisect works nicely but what I like to do is do it manually by using branches. I select a commit that is good and create a branch, call it "good". Then I start by finding a commit in the middle and testing it. If it's good, then I create a branch on a commit between this one and the master, otherwise, I create a branch on a commit that's below the middle branch selected. This is done iteratively and is basically a binary sort. It means I check less commits and I have more fine control than bisect. Usually I use gitk to checkout to each of the branches. The other benefit is if you find something, you can work on a separate branch and not affect the rest. For example

Master Commit
.
. 
.
Test Commit  <---- This one is good, so keep selecting commits above until you fail
.
.
.
Middle Commit  <--- Create branch and checkout. This one is good, so go above
.
.
.
Good Commit
Gustavo Litovsky
  • 2,457
  • 1
  • 29
  • 41
  • 1
    Just FYI, this is exactly what `bisect` does except it doesn't create all of the extra branches. When it finds the bad commit, you can just `checkout -b` and create a branch there. – Wesley Wiser Nov 26 '12 at 22:26
  • After looking at bisect I realized this was the case. I didn't realize I was doing it manually. Still, I personally prefer to do this manually since I often find that sometimes I need to go back to a branch to find something and when bisect is doing it, I might interfere with it. In any case, creating branches and removing them takes a few seconds in gitk. – Gustavo Litovsky Nov 27 '12 at 19:29