简体   繁体   English

git 中将上游分支的新更改获取到功能分支的最干净的方法

[英]cleanest way in git to get new changes to upstream branch to a feature branch

When I create a feature branch based off of an upstream branch, the feature branch will retain its branched off commit as the base of the upstream branch, when the upstream branch gets new changes merged in, what is the cleanest way of updating the feature branch's based off commit?当我基于上游分支创建功能分支时,功能分支将保留其分支提交作为上游分支的基础,当上游分支合并新更改时,更新功能分支的最干净的方法是什么基于提交? the way I usually do it is我通常这样做的方式是

# checked out feature branch
git pull origin upstream-branch

the problem with this method is it creates a new commit in the commit tree and is not very clean, I haven't worked with rebase so a comprehensive guide for this use case would be fantastic这种方法的问题是它在提交树中创建了一个新的提交并且不是很干净,我没有使用过rebase所以这个用例的综合指南会很棒

a visual of what I want to happen:我想要发生的事情的视觉效果:

before:前:

    feature branch  o--o--o--o
                   /
upstream commits  /  new changes
--o--o--o--o--o--o--o--o

after:后:

        feature branch    o--o--o--o
                         /
upstream commits        /
--o--o--o--o--o--o--o--o

pull -r auto-rebases your feature branch changes. pull -r auto-rebases 您的功能分支更改。

Provided there are no conflicts, this should work smoothly.如果没有冲突,这应该可以顺利进行。

# checked out feature branch
git pull -r origin upstream-branch

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

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