Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bisect everything, from initial commit

Tags:

Say I have a small project with a very fast test script, and I just want to bisect everything, from the initial commit to the curret commit. How can I do that?

To clarify, I don't want to waste time identifying a commit that is good and a commit that is bad, so I'm looking for a quick way to mark the latest commit as bad, and the initial commit as good.

like image 692
Zaz Avatar asked Jul 09 '14 15:07

Zaz


People also ask

How do I remove a bad commit in git bisect?

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.

What is git bisect how can you use it to determine the source of a regression bug?

The git bisect command is a fantastic tool that can help you determine which commit introduced the bug. A regression bug is a specific type of software bug that prevents a feature or software from working when it was working before the bug was introduced. Just remember, git bisect won't "fix" the broken commit for you.


1 Answers

git bisect start
git bisect good
git bisect bad `git rev-list --max-parents=0 HEAD`
git bisect run ./test.sh

Or incorporate these commands into an alias, e.g.:

bisect-all = !git bisect start && git bisect bad &&\
        git bisect good `git rev-list --max-parents=0 --first-parent HEAD`

And then just use git bisect-all, git bisect run ./test.sh.

Creating an alias to handle the whole process is slightly more complicated:

quick-bisect = !sh -c 'git bisect start && git bisect bad &&\
        git bisect good `git rev-list --max-parents=0 --first-parent HEAD` &&\
        git bisect run "$@" && git bisect reset' -

But with that, you can simply run git quick-bisect ./test.sh.


If you're using a version of git older than 1.7.4.2, you won't have the --max-parents option, so will need to use something like git rev-list HEAD | tail -n 1 instead.

like image 107
Zaz Avatar answered Nov 15 '22 20:11

Zaz