With git bisect we can zoom in on when a problem might have been introduced between commits.
I was wondering if there is also a way to have git go through (combinations) of files within a single commit, so you can figure out which file / part is causing the trouble?
You use it by first telling it a "bad" commit that is known to contain the bug, and a "good" commit that is known to be before the bug was introduced. Then git bisect picks a commit between those two endpoints and asks you whether the selected commit is "good" or "bad".
It continues narrowing down the range until it finds the exact commit that introduced the change. In fact, git bisect can be used to find the commit that changed any property of your project; e.g., the commit that fixed a bug, or the commit that caused a benchmark's performance to improve.
Bisect has the command git bisect run , which will run a command for you on each iteration. If the command succeeds it will mark the commit as good, if the command fails it will mark the commit as bad.
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. Push to the remote repository.
The recommended way to split a commit is with git rebase -i $commit_you_want_to_split^
. Chop up your commit with the edit
rebase action then a reset HEAD^
and a bunch of git add
s to insert your new smaller commits into the index. Admittedly this isn't automatic, but you might be able to script it with a lot of sed
or awk
or python. See the the SO links above for more details.
Once your commit is chopped up, your git bisect
will now be much more precise.
Has anyone automated this process?
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