简体   繁体   中英

Git merge branch from origin

I have a bunch of remote (tracking) branches that I have created local branches from (so I can write, commit and push) eg. origin/myfeature . Now I would like to merge origin/myfeature into master .

I could do (assuming that I am currently on master):

git merge origin/myfeature

but is this guaranteed to pull latest changes (or be identical to what is in the central "truth") before performing merging?

As I understand locale remote tracking branches are not necessarily pointing to the latest remote changes on the branch.

You do a fetch , that gets a snapshot of the origin. Then merge that snapshot. Certainly on origin it could gain some more stuff.

If you're concerned about that race, you can do another fetch before pushing your changes to see if it moved. But still someone could add another commit before or during the time you push.

But before getting too excited about that, suppose you won the race. But someone added a patch just after your merge. Is that different in any practical way?

In DVCS it's normal that additions happen, if they do, you do another merge to pick up the new stuff. And races are not so interesting.

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