Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to `git bisect` only on one branch's commits?

In a project I am currently working on, we keep each feature its own brach and merge it back to master when the feature is ready. The commits inside each feature branch might include a lot of "WIP" and breaking functionality of other features until it is complete and stable.

Anyway, since the master branch's commits are the only (supposedly) stable ones, I want to git bisect only on that branch.

Is there a way to limit git bisect only on one branch?

like image 427
Kostas Avatar asked Nov 27 '13 10:11

Kostas


People also ask

How do I remove a bad commit in git bisect?

Use git log to check the previous commits. 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.


1 Answers

There is no easy way to accomplish this without further work. After playing with it for a little while I have something that might help you.

git bisect start master f9d5924  for rev in $(git rev-list f9d5924..master --merges --first-parent); do   git rev-list $rev^2 --not $rev^ done | xargs git bisect skip 

This starts git bisect with f9d5924 as your good commit and master as your bad commit. Then it finds the ancestors of the right side of each merge commit that are not on the left side. It passes those ancestors to git bisect skip to skip them. However when it figures out which commit is bad it will show all possible skipped commits from the bad merge commit. like the following

$ git bisect good There are only 'skip'ped commits left to test. The first bad commit could be any of: 0622204625d8817c5d8fd1a2a68b3aa91f2dcdf9 0c771566b9e77e3bdc0a66a7404c8eae9f321a68 5098b44f43f84b213eaab110073a6acd26a5cc02 8b05a808d5e15852fbddaa529ba241fdac8ff693 b0c755c3fa57e3c8d527e76fae38bc9925c01353 We cannot bisect more! 

In this case b0c755c3fa57e3c8d527e76fae38bc9925c01353 was the merge commit it failed on.

Note: This will not work if you have an octopus merge (a merge that merges more than two branches together).

like image 163
Tom Miller Avatar answered Sep 28 '22 00:09

Tom Miller