[英]<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?
[英]Git: Change branch I have branched off of
对于一项新功能,我从当前的dev分支(不是master)在Git中创建了一个分支,并在本地实现了一些更改,但未提交。 然后我被束缚了,开发继续进行。 我用作基础的分支现已关闭,并且有一个新分支。
如何更改功能分支,使其以新的dev分支为基础?
master --
\-- dev 1
\-- feature
\-- dev 2
现在我想移动功能,因为它分支到了dev 2,然后提交了我的更改:
master ---
\-- dev 1
\-- dev 2
\-- feature
当然,在不丢失其他人可能做出的提交的情况下,也可以将其添加到功能分支。
你需要
git rebase dev1 feature --onto dev2
(如果我没记错的话,您可能需要dev1^
但我不相信)。
看起来您必须在dev2
分支的顶部添加尚未提交的dev2
。 如果我弄错了,请纠正我。
git stash save -u "My feature" # stash all changes
git branch -d feature # delete old feature branch
git checkout dev2
git branch -b feature # create new feature branch
git stash apply # unstash all you changes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.