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.
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 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.
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.
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