When we find a new bug in our applications or a test randomly fails in CI, frequently, the bug came to exist as the unintended side effect of anoth...
For further actions, you may consider blocking this person and/or reporting abuse
But what if I am not trying to find the transition between a good and a bad state. What if I am trying to find some other change, like when we added some particular function?
Well, the "test" to execute would be 'git grep theFunctionName'. But the 'good' followed by 'bad' is exactly the opposite logic to use.
You can change the names of what you use to indicate the transition. In this case:
git bisect start --term-old=dne --term-new=exists
git bisect exists
git bisect dne someOldhash
git grep -q theFunctionName && git bisect exists || git bisect dne
Repeat the last command until you get output.
Cool! Yeah this is a contrived example, but for people unfamiliar it's useful. The cool thing about git is that it can be used really creatively to solve problems like this really quickly.
Thanks Jacob, really cool blog post! 👍
git bisect
is great, but it's even better when combined with micro commits. This really helps to pin down faulty code.Thanks for explaining it so well! I really struggle to understand when I'd use this in my workflow, and you did a great job showing examples of that.
So, if all the tests ran on every commit, this would be less useful- unless they were something like performance tests that were relatively subjective.
Usually I try and find the bug, then look at the history for that line or file to see why that change was made, in effect doing almost the opposite of bisect.
I'll try and use bisect, see if it improves my!
Yes, the real beauty of bisect is that it does a binary search, which makes it way faster and easier to find the broken commit
Git bisect is amazing. It has saved me several times!
I think it's great, but I've found a lot of developers are afraid of it because it seems complicated.
It definitely intimidated me when I was first getting familiar with Git. But once I was trying to find a big one commit at a time, and decided to give it a try. Now it’s my go to tool for finding a bad commit!
Nice summary! Gives insight beside listing the necessary commands. Would be nice to have a part 2 that shows the automation of the whole thing by passing a shell script to bisect.
Very easy to grasp! Thanks
Great tutorial - very easy to follow. Thanks!
Thanks so much for this!
No problem, glad someone finds it useful. 🤠