Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Similar trick to git bisect WITHIN a commit

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?

like image 829
PascalVKooten Avatar asked Mar 15 '15 00:03

PascalVKooten


People also ask

How do you use git bisect to find the commit?

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

Is git bisect useful?

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.

What is the command for git bisect?

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.

How do I remove a bad commit in git bisect?

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.


1 Answers

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 adds 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?

like image 168
hobs Avatar answered Nov 13 '22 10:11

hobs