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