![](/img/trans.png)
[英]<GIT> I have branched off a branch and want to push my changes. Do I push changes to the original branch or merge the two branches?
[英]I branched off the wrong branch, how do I move my changes to correct branch?
要复制来自feature
的提交,并且只复制它们(在从它派生的feature
之前或之后没有来自develop
的提交),您可以使用以下命令:
git checkout -B feature release # Checkout `release` and bring `feature` along
git cherry-pick develop..feature@{1} # Retrieve commits from `feature` which are not on `develop`
试试这个命令(伪代码:正确应用你的命名)
git checkout release
git rebase feature
在这些命令之后,您将在release
分支的feature
分支中进行工作。
但是,如果在检出feature
分支后develop
已接受提交,则这些提交将不存在,也不存在于feature
或release
中。
您需要将release
分支重新设置为 master 以便将它们放在release
分支中。 通过运行:
git checkout release
git rebase develop
PS这里是描述rebase
命令https的链接://git-scm.com/docs/git-rebase
我认为最好的方法是将您的功能分支重新定位到发布。 git rebase 命令非常灵活。 您可以告诉它要将分支移动到哪里,以及要移动多少分支。
此命令会将 Feature 分支移至 Release 分支,从 Develop 分支之后的提交开始:
git rebase --onto Release Develop Feature
或者:
git checkout Feature
git rebase --onto Release Develop
无需创建新分支或删除原始分支。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.