Git - Pull dev and out-of-sync feature branch to new feature branch

Viewed 39

I have a new feature branch, say feature-me which is checked-out from dev branch. There is also another feature branch feature-external which is not in sync with dev. When I do git pull feature-external on feature-mine, it overwrites the dev branch to have only feature-external's past dev branch code.

feature-external              feature-me (want feature-external and dev code)
|                             |
------------------dev-----------

How do I do git pull on feature-me to have code frim both dev and feature-external

2 Answers

Try and see if you reproduce the issue with:

 git fetch
 git switch feature-me
 git merge origin/feature-external

Another approach would be:

 git fetch
 git switch feature-me
 git rebase origin/feature-external

In order to relocate your feature-me branch on top of feature-external latest code.

You may have your pull.rebase config option set to true. You can check this by running :

git config pull.rebase

(if nothing is output, my guess was wrong ; if it outputs 1 or true, it is indeed turned on)


Instead of using git pull, you may run the two commands git fetch and git merge yourself :

git fetch origin
git merge origin/feature-external
Related