我正在阅读 man
git format-patch
页:
There are two ways to specify which commits to operate on.
- A single commit,
<since>
, specifies that the commits leading to the tip of the current branch that are not in the history that leads to the<since>
to be output.......
我对“commits ... that are not in the history that leads to the <since> to be output.
”的理解很困惑。我认为应该是“......那些历史上没有......”。
最佳答案
措辞可能令人困惑,因为英语语言解析很棘手,但这就是它的意思:
A single commit,
<since>
, specifies that
- the commits leading to the tip of the current branch
that are not in
- the history that leads to the
<since>
to be output.
为了更容易理解,请从绘图开始:
______________________________
...--o--o--<since>--o--o--o--o <-- currentbranch (HEAD)
__________________
我编号为 2 的部分,导致 <since>
的历史,是带下划线的部分。我编号为 1 的部分,导致当前分支尖端的提交,是带有上划线的部分。整个表达式相当于“带上划线的集合,减去带下划线的集合”,它在 之后留下提交 — 并且排除— <since>
, 包括 HEAD
.
这也是git rev-list
(因此 git log
)意味着当你写:
<since>..HEAD
请注意,如果历史有分支,结果可能会有点出乎意料:
...--o--o--*--*--*--*---* <-- currentbranch (HEAD)
\ /
o--<since>--*
在这种情况下,<since>..currentbranch
包含的提交那些标有*
的.这对 git format-patch
来说不是特殊的: 当您使用拼写为 <since>..currentbranch
的语法时,它适用于所有 基于提交图的操作或 <since>..HEAD
或 <since>..
(所有这三个表示同一件事)。
(可能令人困惑,git diff
不执行基于提交图的操作,因此如果您尝试将您的理解建立在 git diff
的行为方式上,您将赢' t 看到了这个效果。大多数人做使用很多确实看到这个效果的一个命令是 git log
本身——但是因为 git log
没有默认情况下绘制图形,发生的事情并不明显。要使其明显,请从 a/the DOG 获得帮助:git log --decorate --oneline --graph <since>..HEAD
。与此相关的日志或木棍,使用 D总是更有趣strong>构建O在线G图表。:-)
关于git - 如何理解git format-patch手册中的 "<since>"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45457214/