在不同的分支中使用旧的提交

时间:2018-03-22 13:41:20

标签: git

我有两个功能分支,已被要求在某些时候合并。现在我需要在合并之后使用其中一个提交仅用于一个分支。有没有简单的方法如何将此提交移动到另一个分支? (据我所知,在此提交中推送的文件在合并后的其他提交中不会更改)

1 个答案:

答案 0 :(得分:0)

你可以使用樱桃挑选。如果你想从一个分支提交到目标分支,那么使用cherry-pick。

git cherry-pick:

checkout/switch to your targeted branch.
> git checkout <targeted branch>

Then use cherry-pick:
>git cherry-pick <commit id>
note: <commit id> is the commit id of another branch you want to use in your 
targeted branch .

Ex:
git cherry-pick f1f17bc7cd4799377a7dbc39211b0f0a5820bf92