简体   繁体   English

将功能分支移动到另一个分支

[英]Move feature branch to another branch

We have a feature branch features/foo created off master that has not yet been merged.我们有一个功能分支features/foo从尚未合并的master创建。

Recently we created a new dev branch so that master only contains releases.最近我们创建了一个新的dev分支,以便master只包含发布。

I therefore need to move features/foo onto dev .因此,我需要将features/foo移到dev

Do I need to create a new branch from dev for the feature and then push to that or is there a better way?我是否需要从dev为该功能创建一个新分支,然后推送到该分支,或者有更好的方法吗?

It sounds like you want to use git rebase :听起来您想使用git rebase

git checkout features/foo
git rebase dev

There is more documentation about the rebase command here .有关于更多的文档rebase命令在这里

If you just want the changes that you checked into features/foo to be applied to dev and not any other changes that were checked into master between the time dev got branched off and your changes, you'd want to use如果您只想将您签入features/foo的更改应用于dev而不是在dev分支和您的更改之间签入master任何其他更改,您会想要使用

git checkout features/foo
git rebase --onto dev master

Doing a straight git rebase [target-branch] may include more changes than you want, depending on your exact branch history.直接执行git rebase [target-branch]可能包含比您想要的更多的更改,具体取决于您的确切分支历史记录。 Source: https://makandracards.com/makandra/10173-git-how-to-rebase-your-feature-branch-from-one-branch-to-another资料来源: https : //makandracards.com/makandra/10173-git-how-to-rebase-your-feature-branch-from-one-branch-to-another

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM