?
This document uses PHP Chinese website manual Release
git-cherry - 查找尚未應(yīng)用于上游的提交
git cherry [-v] [<upstream> [<head> [<limit>]]]
確定在<head>..<upstream>
那里的提交是否有與<limit>..<head>
范圍內(nèi)的提交相同。
刪除空格和行號(hào)后,基于 diff 等同性測(cè)試。因此, git-cherry 可以檢測(cè)提交何時(shí)通過(guò) git-cherry-pick [1],git-am [1]或git-rebase [1] 被“復(fù)制”。
在<limit>..<head>
輸出每個(gè)提交的 SHA1 ,前綴-
為<upstream>(<上游>)中的等價(jià)提交,以及不提交+
的提交。
-v
顯示 SHA1 旁邊的提交主題。
<upstream>
上游分支來(lái)搜索等效提交。默認(rèn)為 HEAD 的上游分支。
<head>
工作分部;默認(rèn)為 HEAD。
<limit>
不要報(bào)告提交到(包括)限制。
git-cherry 經(jīng)常用于基于補(bǔ)丁的工作流程(請(qǐng)參閱gitworkflows [7])以確定上游維護(hù)人員是否應(yīng)用了一系列補(bǔ)丁。在這樣的工作流程中,您可以創(chuàng)建并發(fā)送如下主題分支:
$ git checkout -b topic origin/master # work and create some commits $ git format-patch origin/master $ git send-email ... 00*
稍后,您可以通過(guò)說(shuō)(仍在topic
)來(lái)查看您的更改是否已應(yīng)用:
$ git fetch # update your notion of origin/master $ git cherry -v
在主題由三個(gè)提交組成的情況下,維護(hù)者應(yīng)用其中兩個(gè)提交時(shí),情況可能如下所示:
$ 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 會(huì)顯示一個(gè)尚未應(yīng)用的簡(jiǎn)要摘要:
$ git cherry origin/master topic- cccc000... commit C+ bbbb000... commit B- aaaa000... commit A
在這里,我們看到提交 A 和 C(標(biāo)記為-
)可以從您的topic
分支中刪除,當(dāng)您重新綁定它origin/master
時(shí),提交 B(標(biāo)記為+
)仍然需要保留,以便它將被發(fā)送以應(yīng)用到origin/master
。
如果您的主題基于其他不在上游的工作,則可選<limit>非常有用。在前面的例子中展開(kāi),這可能看起來(lái)像:
$ 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
通過(guò)指定base
限制,您可以避免列出base
和topic
之間的提交:
$ git cherry origin/master topic base- cccc000... commit C+ bbbb000... commit B- aaaa000... commit A