git - 我如何使用 git bisect 找到第一个 GOOD 提交?

标签 git bisect

我有以下问题:

  • master 的版本工作正常
  • master 之前的最后一个标签的版本(比如 last)有一个错误
  • 一位同事需要为他的上次修订版打个补丁

好的。让我们向我们的 friend git bisect 询问修复错误的修订版:

git bisect start
git bisect bad last
git bisect good master

但这行不通:

Some good revs are not ancestor of the bad rev.
git bisect cannot work properly in this case.
Maybe you mistake good and bad revs?

有什么克服这个问题的提示吗?我是否遗漏了文档中的内容?

最佳答案

从 git 2.7 开始,您可以使用参数 --term-old 和 --term-new。

例如,您可以这样识别问题修复提交:

git bisect start --term-new=fixed --term-old=unfixed
git bisect fixed master
git bisect unfixed $some-old-sha1

在测试时,根据需要说 git bisect fixedgit bisect unfixed

旧答案,适用于 2.7 之前的 git 版本

与其暂时训练自己认为坏就是好,好就是坏,为什么不创建一些别名呢?

~/.gitconfig 添加以下内容:

[alias]
        bisect-fixed = bisect bad
        bisect-unfixed = bisect good

您可以这样开始识别问题修复提交:

$ git bisect start
$ git bisect-fixed master
$ git bisect-unfixed $some-old-sha1

在测试时,根据需要说 git bisect-fixedgit bisect-unfixed

关于git - 我如何使用 git bisect 找到第一个 GOOD 提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15407075/

相关文章:

git - 是否有可以解决错误 : remote branch 'refs/heads/foo/bar' not found? 的 git 命令

Python:两个列表之间的快速映射和查找

git - 我如何停止 git bisect?

git - 我可以在我的存储库的一部分上使用 git bisect 吗?

python - 使用二分法查找列表中 f(x) 变化的位置(在 Python 中)

ruby-on-rails - 使用 Git 和 Heroku 进行适当的持续集成和持续部署

git pull 不工作

git - 将 git 文件历史记录保存为多个文件

Git克隆ssh,用户名、路径和不同驱动器中带有空格

git - 使用 --amend 重写提交后 CodeCommit 失败