I have the following problem:
master
works finemaster
(say last
) has a buglast
revision for that certain bugOkay. Let's ask our friend git bisect
for the revision that fixed the bug:
git bisect start git bisect bad last git bisect good master
But that's not going to work:
Some good revs are not ancestor of the bad rev.
git bisect cannot work properly in this case.
Maybe you mistake good and bad revs?
Any hints to overcome this? Did I miss something in the docs?
For example, git bisect reset bisect/bad will check out the first bad revision, while git bisect reset HEAD will leave you on the current bisection commit and avoid switching commits at all.
Use git log to check the previous commits. Use Git Bisect to find the commit in which line 2 is changed from 'b = 20' to 'b = 0.00000'. Remove the bad commit by using Git Revert. Leave the commit message as is.
The git bisect command is used to discover the commit that has introduced a bug in the code. It helps track down the commit where the code works and the commit where it does not, hence, tracking down the commit that introduced the bug into the code.
Git Bisect — use binary search to find the commit that introduced a bug. Git Bisect is a handy tool used for debugging, it uses Binary Search to go through the previous commits to find out the exact commit that introduced the regression/bug in the code.
As of git 2.7, you can use the arguments --term-old and --term-new.
For instance, you can identify a problem-fixing commit thus:
git bisect start --term-new=fixed --term-old=unfixed git bisect fixed master git bisect unfixed $some-old-sha1
As you test, say git bisect fixed
or git bisect unfixed
as appropriate.
Old answer, for versions of git prior to 2.7
Instead of temporarily training yourself to think that bad means good and good means bad, why not create some aliases?
In ~/.gitconfig
add the following:
[alias] bisect-fixed = bisect bad bisect-unfixed = bisect good
You can start identifying a problem-fixing commit thus:
$ git bisect start $ git bisect-fixed master $ git bisect-unfixed $some-old-sha1
As you test, say git bisect-fixed
or git bisect-unfixed
as appropriate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With