简体中文 ▾
主题 ▾
最新版本 ▾ git-cherry 上次更新于 2.0.5
git-cherry 手册的变更
设置和配置
获取和创建项目
基本快照
分支与合并
共享和更新项目
检查和比较
打补丁
调试
电子邮件
外部系统
服务器管理
指南
管理
底层命令
- 2.1.4 → 2.50.1 无变更
-
2.0.5
2014-12-17
描述
确定在 <head>..
<upstream> 范围内的提交是否与 <limit>..
<head> 范围内的提交等效。
等效性测试是基于 diff (在去除空白和行号后) 进行的。因此,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
在这里,我们看到提交 A 和 C(标有 -
)在您将 topic
分支 rebase 到 origin/master
上时可以从您的分支中移除,而提交 B(标有 +
)仍然需要保留,以便将其发送以应用到 origin/master
。
使用限制
可选的 <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
指定为限制,您可以避免列出 base
和 topic
之间的提交
$ git cherry origin/master topic base - cccc000... commit C + bbbb000... commit B - aaaa000... commit A