将多次提交构成的功能合并到另一个项目中

时间:2018-08-03 20:01:59

标签: git

有一个tennis功能,该功能由多次提交构成,我需要将该功能合并到另一个项目中。

考虑以下时间轴:

- x - tennisV1 - x - x - tennisV2 - x - tennisV3 - x - x - x - x - x - tennisV4

我想要这个:

- tennisV1 - tennisV2 - tennisV3 - tennisV4

我该怎么做?

我当时正在考虑显示合并的所有提交内容的区别,以帮助我,但是我不知道如何在不显示不相关的提交内容之间进行更改的情况下( x commits

我正在使用git和bitbucket,所以如果有视觉效果,那也很好。

1 个答案:

答案 0 :(得分:1)

就像melpomene在注释中建议的那样,这几乎是cherry-pick命令的典型工作:

# let's checkout the target branch, where you want to put the tennis commits
git checkout <yourTargetBranch>

# and now instead of merging we only take what's needed
git cherry-pick tennisV1 tennisV2 tennisV3 tennisV4

仅在您选择的提交之间(在模式中为x),不会出现中间提交。