English ▾
git-cherry 手册的本地化版本
主题 ▾
最新版本 ▾ git-cherry 上次更新于 2.0.5
git-cherry 手册中的更改
设置和配置
获取和创建项目
基本快照
分支和合并
共享和更新项目
检查和比较
补丁
调试
电子邮件
外部系统
服务器管理
指南
管理
底层命令
- 2.1.4 → 2.49.0 无更改
-
2.0.5
2014-12-17
描述
确定 <head>..<upstream>
中是否存在与 <limit>..<head>
范围内的提交等效的提交。
等效性测试基于差异,在删除空格和行号之后。 因此,git-cherry 会检测到何时通过 git-cherry-pick[1]、git-am[1] 或 git-rebase[1]“复制”了提交。
输出 <limit>..<head>
中每个提交的 SHA1,前缀为 -
,表示该提交在 <upstream> 中具有等效项,前缀为 +
,表示该提交没有等效项。
示例
补丁工作流
git-cherry 经常在基于补丁的工作流中使用(请参阅 gitworkflows[7]),以确定上游维护者是否已应用一系列补丁。 在这样的工作流中,您可以创建并发送一个主题分支,如下所示
$ git checkout -b topic origin/master # work and create some commits $ git format-patch origin/master $ git send-email ... 00*
稍后,您可以通过说出(仍然在 topic
上)来查看您的更改是否已应用
$ git fetch # update your notion of origin/master $ git cherry -v
具体示例
在主题包含三个提交,并且维护者应用了其中两个提交的情况下,情况可能如下所示
$ git log --graph --oneline --decorate --boundary origin/master...topic * 7654321 (origin/master) upstream tip commit [... snip some other commits ...] * cccc111 cherry-pick of C * aaaa111 cherry-pick of A [... snip a lot more that has happened ...] | * cccc000 (topic) commit C | * bbbb000 commit B | * aaaa000 commit A |/ o 1234567 branch point
在这种情况下,git-cherry 会显示一个简洁的摘要,说明还有哪些内容尚未应用
$ git cherry origin/master topic - cccc000... commit C + bbbb000... commit B - aaaa000... commit A
在这里,我们看到当您将 topic
分支变基到 origin/master
之上时,可以从您的 topic
分支中删除提交 A 和 C(标记为 -
),而提交 B(标记为 +
)仍然需要保留,以便将其发送到 origin/master
应用。
使用 limit
在您的主题基于上游中没有的其他工作的情况下,可选的 <limit> 非常有用。 在前一个示例的基础上进行扩展,这可能看起来像
$ git log --graph --oneline --decorate --boundary origin/master...topic * 7654321 (origin/master) upstream tip commit [... snip some other commits ...] * cccc111 cherry-pick of C * aaaa111 cherry-pick of A [... snip a lot more that has happened ...] | * cccc000 (topic) commit C | * bbbb000 commit B | * aaaa000 commit A | * 0000fff (base) unpublished stuff F [... snip ...] | * 0000aaa unpublished stuff A |/ o 1234567 merge-base between upstream and topic
通过将 base
指定为 limit,您可以避免列出 base
和 topic
之间的提交
$ git cherry origin/master topic base - cccc000... commit C + bbbb000... commit B - aaaa000... commit A
GIT
属于 git[1] 套件的一部分