简体   繁体   中英

Git merge from another branch - 3 different methods - will all work correctly?

I'm working on branch MyFeature, which was created based on branch Develop.

From what I understand, there are (at least) 3 ways to merge Develop back to MyFeature, when I'm checked out on MyFeature:
a. checkout Develop, pull, checkout MyFeature, merge from Develop
b. git fetch, merge from origin/Develop
c. git pull from origin/Develop

I don't like method a (the one I used most before I switched to using method b) cause it's too long and confusing.

Will all these methods produce the same result?

Thanks!

Yes , all of these boil down to:

  1. git fetch (implied in git pull scenarios)
  2. git merge origin/develop

Your method a adds a step but keeps your local Develop up-to-date. Might be worth or not, depending on the context.

If you pull remote changes with the flag --rebase, then your local changes are reapplied on top of the remote changes.

git pull --rebase

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