English ▾
git-cherry 手冊的本地化版本
主題 ▾
最新版本 ▾ git-cherry 最後更新於 2.0.5
git-cherry 手冊的變更
設定與配置
取得與建立專案
基本快照
分支與合併
分享與更新專案
檢視與比較
修補
除錯
電子郵件
外部系統
伺服器管理
指南
管理
底層命令
- 2.1.4 → 2.47.0 無變更
-
2.0.5
12/17/14
描述
判斷在 <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
具體範例
在 topic 包含三個提交,而維護者套用了其中兩個提交的情況下,情況可能如下所示
$ 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
在這裡,我們看到當你在 origin/master
之上重新設定分支時,提交 A 和 C(標記為 -
)可以從你的 topic
分支中刪除,而提交 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
GIT
屬於 git[1] 套件的一部分