linux - git 如何处理几个补丁中的一个?

标签 linux git patch

假设我们有一个文件的 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/

相关文章:

regex - Grep 特定长度的字符

linux - 如何在同一个输入中执行多个命令

linux - 在 Linux 中物理连续与几乎不连续

git - 如何排除除所有顶级点文件和子目录之外的所有内容?

git - 如何在 Git 中显示本地和远程文件之间的差异?

java - Java 中的 Linux 命令 "write all used jars by JVM to file"

macos - 如何在mac中将git从中文改成英文

patch - 补丁文件的格式是什么?

Powershell 代码在从文本文件读取每个值后打印/换行

dynamic - 如何为 nginx 设置动态 client_max_body_size