本文介绍了在git中,我如何从一个分支中删除一个提交并将其应用到另一个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个主分支,每个分支都有一个不同的特征,然后我有一个合成分支将这两个分支结合在一起。我向综合分支承诺了一些东西,但是现在我发现我宁愿将这种改变应用到特定分支的其中一个分支上。有没有办法做到这一点不适用/适用于其他地方使用git?

I have two branches off of master, each one for a different feature, and then I have a synthesis branch that combines the two. I committed something to the synthesis branch, but now I see I would have rather applied that change to one of the branches particular to that feature. Is there a way to do this unapply/apply somewhere else maneuver with git?

推荐答案

source 分支移动到 target ,请执行:

Cherry-pick commit to target branch and reset source branch. Assuming, you want to move the latest commit from source branch to target, do:

git checkout target
git cherry-pick source
git checkout source
git reset --hard source^

如果提交不是最后一个,您必须使用 git rebase -i 而不是最后一个命令,并为 cherry-pick 选择特定的提交名称。

If the commit wasn't the last, you will have to use git rebase -i instead of the last command and choose specific commit name for your cherry-pick.

这篇关于在git中,我如何从一个分支中删除一个提交并将其应用到另一个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 20:54