directory search
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
characters

名称

git-cherry - 查找尚未应用于上游的提交

概要

git cherry [-v] [ [ []]]

描述

确定在..那里的提交是否有与..范围内的提交相同。

删除空格和行号后,基于 diff 等同性测试。因此, git-cherry 可以检测提交何时通过 git-cherry-pick [1],git-am [1]或git-rebase [1] 被“复制”。

..输出每个提交的 SHA1 ,前缀-(<上游>)中的等价提交,以及不提交+的提交。

选项

-v

显示 SHA1 旁边的提交主题。

上游分支来搜索等效提交。默认为 HEAD 的上游分支。

工作分部;默认为 HEAD。

不要报告提交到(包括)限制。

示例

补丁工作流程

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分支中删除,当您重新绑定它origin/master时,提交 B(标记为+)仍然需要保留,以便它将被发送以应用到origin/master

使用限制

如果您的主题基于其他不在上游的工作,则可选非常有用。在前面的例子中展开,这可能看起来像:

$ 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限制,您可以避免列出basetopic之间的提交:

$ git cherry origin/master topic base- cccc000... commit C+ bbbb000... commit B- aaaa000... commit A
Previous article: Next article: