git cherry-pick和git show之间有什么区别? patch -p1? [英] What are the differences between git cherry-pick and git show | patch -p1?
问题描述
我遇到了一个情况,其中 git cherry-pick X
会有一些冲突,但是也会创建额外的插入(当使用 git diff
)。
然后我重新运行 git show X> my.patch
,然后做 patch -p1< my.patch
在我的树上。
我得到了更好的结果,有些冲突,但结果更加清晰。
git对樱桃挑选有什么特别之处?我使用git 1.7.0.4。
编辑:
通过更清晰的结果,我的意思是生成的树匹配更多的结果 git show X
,而 git cherry-pick
包含更多的代码。
git commit -c< original-commit>
复制像cherry-pick那样的元数据。樱桃挑选还有一些额外的选项可能会有帮助,并且可以接受多个提交(可能指定为rev-list范围)。 patch
显然不支持这些。 我不确定您的说法,即结果是清洁器。你是否建议git应用差异比 patch
做的不同?
I ran into a situation where git cherry-pick X
would have some conflicts, but also created extra inserts (when verified with git diff
).
I then re-ran git show X > my.patch
, and then did patch -p1 < my.patch
on my tree.
I got better results, some conflicts, but a much cleaner result.
What does git does special with cherry-picks? I use git 1.7.0.4.
Edited:
By cleaner results, I mean the resulting tree matched a lot more the results of git show X
, whereas the git cherry-pick
included a lot more code.
When you cherry-pick a commit, it commits the result using all the metadata of the commit, not just the diff it represents - you'll get the original commit message and author. Your patch pipeline will get you the working tree contents that you want, but then you'll have to commit it yourself, hopefully with git commit -c <original-commit>
to copy the metadata like cherry-pick would have. Cherry-pick also has some additional options that could be helpful, and can accept multiple commits (perhaps specified as a rev-list range). patch
obviously doesn't support any of that.
I'm not sure about your assertion that the result was "cleaner". Are you suggesting that git applied the diff differently than patch
did?
这篇关于git cherry-pick和git show之间有什么区别? patch -p1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!