简体   繁体   English

从提交合并到功能分支

[英]Merging from commit to feature branch

On Monday morning I create a feature branch from what I think is a stable commit. 在星期一早上,我根据我认为是稳定的提交创建功能分支。 I work away and then I find out there are a few commits on the develope branch I need in my feature branch. 我工作了,然后发现在功能分支中需要对develope分支进行一些提交。 It's not just one or two - in which case I'd consider cherry pick. 不只是一两个,在这种情况下,我会考虑选择樱桃。 It's 30 / 40, so I'd prefer to merge everything from develop into my feature branch. 它是30/40,所以我更喜欢将开发内容整合到我的功能分支中。

What is the best way to do this? 做这个的最好方式是什么?

如果您尚未推送功能分支,则只需对其重新设置基础,以使该分支与开发分支分离,此时该分支已经包含了所需的新提交...

I would just merge main branch (eg master) into my feature branch like this 我将像这样将主分支(例如母版)合并到功能分支中

### Ensure everything is commited
$ git add -A .
$ commit -m "My message"

Suppose your repo looks like this 假设您的仓库看起来像这样

*---*---*---*---*---*----<30-40 commits>-*---* (master)
             \
              \---*---*--<your work>--*---* (feature1)

Now merge master into my feature branch 现在将master合并到我的功能分支中

$ git merge master

### Inspect the situation
$ gitk --all

You should see something like this 你应该看到这样的东西

*---*---*---*---*---*----<30-40 commits>-*---* (master)
             \                                \
              \---*---*--<your work>--*---*----* (feature1)

Now the master branch wasn't changed at all but your feature branch is up-to-date. 现在master分支根本没有更改,但是您的Feature分支是最新的。 You can continue working on it now. 您现在可以继续进行操作。

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

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