为什么git log --cherry-pick没有删除等价的提交? [英] Why is git log --cherry-pick not removing equivalent commits?

查看:125
本文介绍了为什么git log --cherry-pick没有删除等价的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用

  git log --no-merges --cherry-pick --right-only master ... my-branch 

生成my-branch中的提交列表,但不在master(按照git-log文档)。但是,列表中还有很多等价的提交。如果我显示他们和他们的补丁,除了提交ID之外没有区别。

  git show 16cbd0e47406a4f7acbd6dc13f02d74d0b6a7621> patcha 
git show c53c7c32dcd84bfa7096a50b27738458e84536d5> patchb

diff patcha patchb
1c1
<提交16cbd0e47406a4f7acbd6dc13f02d74d0b6a7621
---
>提交c53c7c32dcd84bfa7096a50b27738458e84536d5

甚至 git patch-id 显示它们是等价的:

  git show c53c7c32dcd84bfa7096a50b27738458e84536d5 | git patch-id 
2b5504fb9a8622b4326195d88c7a20f29701e62b c53c7c32dcd84bfa7096a50b27738458e84536d5
git show 16cbd0e47406a4f7acbd6dc13f02d74d0b6a7621 | git patch-id
2b5504fb9a8622b4326195d88c7a20f29701e62b 16cbd0e47406a4f7acbd6dc13f02d74d0b6a7621

git log - -cherry-pick 不把它们当成重复项?

解决方案

自从做樱桃采摘? - cherry-pick 首先通过匹配提交ID进行工作,然后如果失败,则查找补丁ID。如果您已将主人合并到您的分支中,那么您现在将在您的分支和樱桃选择的版本上进行实际提交。所以它会找到提交ID,然后继续报告樱桃选择的版本。



我经常想知道git是否应该总是检查两者,但这很可能相当可观的表现。

I have been trying to use

git log --no-merges --cherry-pick --right-only master...my-branch

to generate a list of commits that are in the my-branch, but not in master (as per the git-log documentation). However, there are still many equivalent commits that are coming up in the list. If I show them and their patches, there is no difference apart from the commit id.

git show 16cbd0e47406a4f7acbd6dc13f02d74d0b6a7621 >patcha
git show c53c7c32dcd84bfa7096a50b27738458e84536d5 >patchb

diff patcha patchb
1c1
< commit 16cbd0e47406a4f7acbd6dc13f02d74d0b6a7621
---
> commit c53c7c32dcd84bfa7096a50b27738458e84536d5

And even git patch-id shows them as being equivalent:

git show c53c7c32dcd84bfa7096a50b27738458e84536d5 | git patch-id
2b5504fb9a8622b4326195d88c7a20f29701e62b c53c7c32dcd84bfa7096a50b27738458e84536d5
git show 16cbd0e47406a4f7acbd6dc13f02d74d0b6a7621 | git patch-id
2b5504fb9a8622b4326195d88c7a20f29701e62b 16cbd0e47406a4f7acbd6dc13f02d74d0b6a7621

How does git log --cherry-pick not pick these up as duplicates?

解决方案

Have you merged master into your branch since doing the cherry picks? --cherry-pick works first by matching the commit id, and then if that fails, looking for the patch id. If you've merged master into your branch, then you'll now have the actual commit on your branch and the cherry-picked version. So it'll find the commit id, and then proceed to report the cherry-picked version.

I've often wondered if git should always check both, but that's probably a considerable performance hit.

这篇关于为什么git log --cherry-pick没有删除等价的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆