简体   繁体   中英

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

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.

Provided there are no conflicts, this should work smoothly.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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