git - 单个缺失提交的 git-cherry 等效项是什么?
问题描述
如何检查单个提交是否已应用于特定分支?
以文档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
依赖于补丁内容(差异),这是问题的关键。
解决方案
git log
有一个--cherry-mark
选项可以添加关于对称差异的信息(又名“3-dots operator” A...B
)
尝试运行:
git log --oneline --graph --boundary --cherry-mark master...topic
您应该看到具有前缀+
(或*
在--graph
选项打开时)的唯一提交,并且两边都有的提交=
。
如果您想知道提交是如何匹配的:git patch-id
计算cherry-pick / rebase 使用的结果。
git patch-id
期望在 STDIN 上有一个补丁(由git show
or产生):git diff
$ git show <commit-ish> | git patch-id
<hash for patch> <hash of input revision, if it can determine a revision>
例如:您可以在以下位置查看patch-id
所有单个提交的 s A...B
:
git rev-list origin/master...forkpoint | while read sha1; do
git show $sha1 | git patch-id
done
您可以在脚本中使用此结果,以更明确地打印提交的链接方式。
推荐阅读
- r - 如何在 R 中的 For 循环中跳过错误。并提取导致错误的 i 列表单独处理它们
- python - Django 根据迁移修复现有数据库
- amazon-web-services - AWS Lambda 和版本上传?
- windows - 为什么命令提示符显示以下错误?
- c++ - 使用 Clang LibTooling 扫描在模板化父类中调用本地类的 C++ 源
- mysql - 我有一个计算并返回客户余额的函数,但它向我返回以下错误
- java - JAVA - 解析 XML 文件未正确存储数据
- java - 深度链接 - 从 Play 商店安装应用时获取数据
- apache - 禁止:您无权访问此服务器上的 / (centos 7)
- keras - 如何加载 .bin 模型文件?