Similar trick to git bisect WITHIN a commit
Asked Answered
S

1

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?

Siegbahn answered 15/3, 2015 at 0:10 Comment(6)
Nope, but this is a good argument for making frequent small commits rather than single very large commits.Edible
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.Nanoid
@Edible I knew that comment would come :-) (and it is correct).Siegbahn
@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.Siegbahn
@Edible 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?Siegbahn
@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.Nanoid
U
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?

Untutored answered 17/5, 2016 at 21:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.