如何检查单个提交是否已应用于特定分支?
以git-cherry文档为例:
$ 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 origin/master topic
- cccc000... commit C
+ bbbb000... commit B
- aaaa000... commit A我怎么知道cccc000有与- cccc111相同的内容而不必处理整个树呢?这个是可能的吗?
注意,git-cherry依赖于修补程序内容(diff),这是问题的关键。
发布于 2020-06-23 12:45:11
git log有一个--cherry-mark选项,它添加关于对称差异的信息(即“3点运算符”A...B)。
试着跑:
git log --oneline --graph --boundary --cherry-mark master...topic您应该看到以+为前缀的唯一提交(或在--graph选项打开时为* ),并在双方都提交以=为前缀的提交。
如果您想知道提交是如何匹配的:git patch-id计算樱桃挑选/重基所使用的结果。
git patch-id期望STDIN上有一个修补程序(由git show或git diff生成):
$ git show <commit-ish> | git patch-id
<hash for patch> <hash of input revision, if it can determine a revision>例如:您可以在patch-id中查看所有单独提交的A...B:
git rev-list origin/master...forkpoint | while read sha1; do
git show $sha1 | git patch-id
done您可以在脚本中使用此结果,以更明确地打印如何链接提交。
https://stackoverflow.com/questions/62534666
复制相似问题