如何仅在一个分支的提交上进行git bisect? [英] How to `git bisect` only on one branch's commits?

查看:95
本文介绍了如何仅在一个分支的提交上进行git bisect?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我当前正在研究的项目中,我们将每个功能保留在自己的分支中,并在功能就绪时将其合并回主版本.每个功能分支中的提交可能包括很多"WIP"和其他功能的破坏性功能,直到功能完整且稳定为止.

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.

无论如何,由于master分支的提交是唯一(据说)稳定的提交,因此我只想在该分支上git bisect.

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

是否可以仅在一个分支上限制git bisect?

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

推荐答案

没有进一步的工作,没有简单的方法可以完成此任务.玩了一会儿后,我有一些可能会对您有所帮助.

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

这以git bisect开头,以f9d5924作为您的良好提交,以master作为您的不良提交.然后,找到每个合并提交右侧的祖先,这些祖先不在左侧.它将那些祖先传递到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!

在这种情况下,b0c755c3fa57e3c8d527e76fae38bc9925c01353是失败的合并提交.

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

这篇关于如何仅在一个分支的提交上进行git bisect?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆