7

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?

hobs
  • 18,473
  • 10
  • 83
  • 106
PascalVKooten
  • 20,643
  • 17
  • 103
  • 160
  • 5
    Nope, but this is a good argument for making frequent small commits rather than single very large commits. – larsks Mar 15 '15 at 00:57
  • Is this a hypothetical question or is there an actual problem you're trying to solve? There might be another way to approach the problem. – Roman Mar 15 '15 at 03:16
  • @larsks I knew that comment would come :-) (and it is correct). – PascalVKooten Mar 15 '15 at 07:36
  • 1
    @R0MANARMY It is based on last week, where a bug was introcuted, I soon discovered in which commit it was, but it took me a long time to find out the exact file. If git would just propose some files and check in etc, then all I'd have to do is reload the page to check the bug. – PascalVKooten Mar 15 '15 at 07:38
  • @larsks My main problem is usually that changing one file is usually part of a bigger plan. Would you really commit 1 file when the success of this single file depends on changes in other files? – PascalVKooten Mar 15 '15 at 07:42
  • 1
    @PascalvKooten Generally no, you wouldn't commit one file unless it represented all the work related to a particular feature or work item. If you often find yourself in a situation where a single work item results in large commits, you may try to see if work items can be broken down further. – Roman Mar 15 '15 at 19:54

1 Answers1

2

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?

Community
  • 1
  • 1
hobs
  • 18,473
  • 10
  • 83
  • 106