为什么樱桃选择改变多个提交? [英] Why cherry-pick pick change more than one commit?

查看:131
本文介绍了为什么樱桃选择改变多个提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有2个分支,比如说branch1和branch2。 branch1中增加了许多新功能,并且branch2是稳定的。今天,我想从branch1合并1个特征到branch2。因此,我只运行 git cherry-pick 。我想应该只有< commit-for-featur1-in-branch1 中的变化才会合并到branch2中。但我发现其他功能还包括更多的变化。



我认为它会得到仅用于指定提交的差异,对吧?

仅供参考,branch1中的提交是从其他开发分支合并的,这是否可能导致此问题?



有什么不对吗?



谢谢。

解决方案

c $ c> git cherry-pick 是否需要您指定的提交并读取它与父级之间的差异。这有效地使补丁。然后它将这个补丁应用到您当前签出的分支。



在您的情况中,提交包含其他功能的添加。您可以通过查看此提交将使用 git log 生成的补丁来仔细检查提交消息是否与您认为该功能相对应:

  git log -p -1 > 

-p 不仅告诉日志显示提交信息,如作者,日期和提交信息,但还包括提交引入的补丁(或差异)。 -1 选项告诉git log在1次提交后停止列出历史记录。


I have 2 branches here, say branch1 and branch2. There are lots of new feature added in branch1, and the branch2 is stable. Today, I want to merge just 1 feature from branch1 to branch2. So, I just run git cherry-pick <commit-for-feature1-in-branch1. I suppose there should be only the change in <commit-for-featur1-in-branch1 will be merged into branch2. But I found there are more changes for other features are included.

I thought it will get the diff just for only that specified commit, right?

FYI, the commit in branch1 was merged from other development branch, does this possibly cause this issue?

Anything wrong I did?

Thanks.

解决方案

What git cherry-pick does is it takes the commit that you specify and reads the difference between it and it's parent. This effectively makes a patch. It then applies this patch to your currently checked out branch.

In your case, the commit contained the addition of other features. You can double check that the commit message corresponds to what you thought the feature was by looking at the patch that this commit would generate with git log:

git log -p -1 <sha1-of-your-commit>

The -p tells log to not only show the commit information like author, date and commit message, but to also include the patch (or difference) that the commit introduces. The -1 option tells git log to stop listing history after 1 commit.

这篇关于为什么樱桃选择改变多个提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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