Git:如何区分两个提交并将该差异应用于第三个提交 [英] Git: How to diff two commits and apply that diff to a third one
问题描述
我有两个提交,B和C.C是B的固定版本,但不是B被修改后的继承者。
我想用最后一次提交将这个修复应用到另一个分支A.
我该怎么做,最好没有中间补丁文件?
I have two commits, B and C. C is fixed version of B but not a successor as B was amended. I want to apply this fix to another branch with last commit A. How can I do that, ideally without intermediate patch file?
C
| B
|/
.
. A <-- I want to apply diff from B to C here.
|/
我认为它可以是 git cherry-pick --no-commit BC
但不是。
I thought it could be git cherry-pick --no-commit B C
but no.
推荐答案
不幸的是,盒子。有一些低级命令像 git read-tree -m
,但它们不提供任何可用的冲突解决方法。
Unfortunately, there is no such command out of the box. There are low-level commands like git read-tree -m
but they do not provide any usable conflict resolution.
最实用的方法是从B到C进行假冒,然后挑选它。这些命令执行它:
The most practical way is to make a fake commit from B to C and then cherry-pick it. These commands do it:
$ git checkout A
$ git cherry-pick --edit $(echo temporary | git commit-tree -p B C^{tree})
来自 man gitrevisions )
这篇关于Git:如何区分两个提交并将该差异应用于第三个提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!