簡體中文 ▾
主題 ▾
最新版本 ▾ 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