如何轻松地 运行 git 干净利落地平分补丁

How to easily run git bisect with patches on top cleanly

我正在尝试 运行 git 平分以找到损坏的提交,但我遇到的问题是,如果没有在顶部应用一系列额外的补丁,损坏并不明显。我只是从另一个分支中挑选那些,但我遇到的问题是,在对分的某些步骤中,它们没有干净地应用并且需要一些修复。这应该不是问题,但在完成修复后我似乎无法继续前进。

例如...

$ git bisect start
djrscally@valhalla:$ git bisect bad
djrscally@valhalla:$ git bisect good tags/v5.14-rc7
Bisecting: 13382 revisions left to test after this (roughly 14 steps)
[1ea3615b6168eaaf07445c8d32a4c6bc965d9579] iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.
djrscally@valhalla:$ git cherry-pick --no-commit 820aca592e0c^..58915847b332
Auto-merging include/acpi/acpi_bus.h
Auto-merging drivers/acpi/scan.c
Auto-merging drivers/i2c/i2c-core-acpi.c
Auto-merging drivers/regulator/Makefile
CONFLICT (content): Merge conflict in drivers/regulator/Makefile
Auto-merging drivers/regulator/Kconfig
CONFLICT (content): Merge conflict in drivers/regulator/Kconfig
error: could not apply 6a7e459bf029... regulator: Introduce tps68470-regulator driver
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'

此时我需要修复 drivers/regulator/Makefile 和 Kconfig;到那时我希望能够继续,但我不能:

djrscally@valhalla:$ git add .
djrscally@valhalla:$ git cherry-pick --continue
error: your local changes would be overwritten by cherry-pick.
hint: commit your changes or stash them to proceed.
fatal: cherry-pick failed

Aaaaaaa,我现在真的不确定该怎么做。 git cherry-pick --skip 似乎重置了早期精选提交的所有更改。我可以放弃 --no-commit,但我不确定 bisect 如何处理我突然在决定平分的点之上放弃大量提交的事实。

我该如何处理?

我的第一次尝试是一次完成整个批次,而不是反复挑选:

git diff 820aca592e0c^..58915847b332 | git apply -3

然后解决冲突,这是最后一步,添加解决方案就可以测试了。

这可能是一些手动 rerere'ing 的好地方,你这样做 mkdir -p `git rev-parse --git-common-dir`/rr-cache 一次告诉 git 你正在使用没有自动化辅助的 rerere,然后 git rerere 当您收到冲突通知时,然后修复所有尚未修复的内容,并在添加解决方案后再次 git rerere