简体   繁体   中英

Git: branched off but parent branch has changed

Here is my scenario:

git checkout master

git pull

Now master is up to date.

We create a new branch and switch to it:

git branch test

git checkout test

As of this point, test and master should be identical, with test being a local branch not visible to remote/origin . (Correct me if this is wrong, but I see no reason why it should be)

Now, somewhere along the way, master is merged with additional branches that affect files that you are working on locally in test . My question is:

Aside from git stash ing the changes so far, deleting the local test branch, and branching off from master again , what is the best way to merge the new changes from master into the local test branch?

As you already mentioned your could merge master into test by

git checkout test
git merge master

which will collect the changes on master branch and apply them in one merge commit on test .

Instead you could also run git rebase master test which will reapply the commits in test onto the new master and give you a linear history.

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