假设我们有一个文件的 5 个补丁,其中 4 个补丁更改了文件内容并添加了新行。但是我们仍然可以将单个补丁 5 应用于 git 树。为什么?因为我认为行号已经改变,所以行内容不再匹配。 git 如何确定我更改了哪一行?通过三行上下文的改变?我不认为这是合理的。
顺便说一句,如何生成像 [PATCH 0/5] 这样的数字零补丁?格式补丁好像只能从0001开始生成。
最佳答案
Through the three line context of the change?
这就是 git apply
描述它:
Ensure at least
<n>
lines of surrounding context match before and after each change.
When fewer lines of surrounding context exist they all must match.
是的,即使 numbers 行发生了变化,上下文仍然是决定是否应用补丁的关键。
关于编号方面,我没有测试,但看看--start-number
git format-patch
command 的选项可以帮助:
--start-number <n>
Start numbering the patches at
<n>
instead of 1.
关于linux - git 如何处理几个补丁中的一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18051587/