Git bisect avoids commit checking (see "Avoid commit checking" on the man page): when you halve and git selects the commit for testing, you can override its selection with git reset --hard <commit you want> .
Using git log , you can find the last commit that affected the file (or subdirectory) - this will return the hash:
git log -1 --pretty=format:%H -- path_that_you_are_interested_in
So, every time git bisect prompts you to check, you should run this command to make sure that you only check the commits that affected somepath :
git reset --hard $(git log -1 --pretty=format:%H -- somepath)
Now there is one more thing that we need to take care of. If there are no interesting commits (i.e., no somepath that modify somepath ) between the last checked good commit and the commit currently selected by git bisect , we may end up in a loop. To avoid this, we should use a conditional sentence:
#!/bin/bash last_good=$(git bisect log | tail -1 | sed 's/git bisect good //') last_interesting=$(git log -1 --pretty=format:%H -- lily/) if [ "$last_good" == "$last_interesting" ]; then
source share