简体   繁体   English

从功能分支创建的重新编制分支

[英]Rebasing branch that was created from a feature branch

I was working on a feature branch that I pushed to origin. 我当时正在开发一个功能分支,该分支已推向源头。 Then I created another feature branch but I didn't checkout master before creating it. 然后,我创建了另一个功能分支,但在创建它之前没有结账母版。 Now my second feature branch has the commits from the first feature branch which aren't yet merged to master. 现在,我的第二个功能分支具有来自第一个功能分支的提交,这些提交尚未合并到master。

I tried to rebase it and update the rebase to origin - unsuccesfully: 我试图重新设置基准并将更新的基准更新为原点-不成功:

git checkout second-feature-branch
git rebase master
git push origin second-feature-branch --force

I already committed to the second branch. 我已经致力于第二个分支。

What I have: 我有的:

A -- B -- master
                \ 
                 \
                  first feature branch
                                      \
                                       second feature branch

What I want 我想要的是

                  second feature branch
                 /
                /
A -- B -- master 
                \ 
                 \
                  first feature branch

How do I keep only the newest commit on the new feature branch and rebase it to master? 如何仅在新功能分支上保留最新的提交并将其重新设置为母版?

What has happened is you created the second feature branch from the first feature branch. 发生的事情是您从第一个功能分支创建了第二个功能分支。 So the second feature branch used the first feature branch as a base. 因此,第二个要素分支使用第一个要素分支作为基础。

To fix it, you can create a new branch after checkout to master and then cherry-pick the commits of the second feature branch into the new branch. 要解决此问题,您可以在签出后创建一个新分支来掌握,然后将第二个功能分支的提交樱桃拾取到新分支中。 Then you will get the branches as you need it 然后,您将根据需要获得分支机构

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

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