git - 如何理解git format-patch手册中的 "<since>"?

标签 git

我正在阅读 man git format-patch 页:

There are two ways to specify which commits to operate on.

  1. 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

  1. the commits leading to the tip of the current branch

that are not in

  1. 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构建O在线G图表。:-)

关于git - 如何理解git format-patch手册中的 "<since>"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45457214/

相关文章:

git - 禁用 (GitGutter) 关于提交 Sublime Text 的消息

linux - 通过从原始 svn 仓库中获取所有 svn 部分来克隆一个 git-svn 仓库

git - 当我在终端中创建一个新分支时,为什么图形不显示从 master 分支分支出来的新分支?

Gitlab:无法创建 ssh key

git - 使用 git-p4 克隆部分 Perforce 仓库

node.js - NPM:不推荐使用存在同步

svn - Subversion 的部分提交

Git:将提交的一部分应用到另一个分支

git - 裸 git repo 的 GUI

python - Visual Studio 中的一个项目有多个团队 - 不好的做法?