How does the merge work?

Asked

Viewed 4,841 times

22

I created another branch as backup and give merge in it, suppose I’m in branch daniela3:

git merge origin/develop

Only my branch daniela3 will be affected or origin/develop too? I mean, I’ll be putting together what’s in origin/develop -> daniela3 and origin/develop remains without my changes OR both are updated?

2 answers

16


Only the repository you are currently in is updated (in this case it should be the daniela3 if I got it right). If you want another repository to be updated (not that it seems to be your case) you will have to do a push for him.

Then the merge is always local. When you want to update another repository you bring your content to your current local repository, you do the merge and sends back the contents of your repository to the original, possibly remote repository.

The merge acts only in the current repository considering the differences to the specific repository that is connected. Any other branches are not considered. If there is need to consider other braches, these should be merged before in the repository due to.

  • When I "git pull" brings me the update (what was sent in "git push") of ALL remote branches? What’s the difference pull VS merge?

  • 1

    Well, that’s another question :) but git pull brings only what is in the repository where you are connecting. If it has branches which have not been merged.

  • I get it, thank you!

3

Just the branch in which you are is affected. In this case, only the branch daniela3.

This is because the branch origin/develop is the source branch. If you view Git branches as graphs, it’s easy to understand that the branch is unaffected. This can be shown visually, with the branch situation before:

                  .----C1<----C2        <- [daniela3]
                 /                    
M1<---M2<---M3<-´---M4<---M5<---M6      <- [origin/develop]

And afterward merge, generating the merge commit C3m:

                  .----C1<----C2<-----C3m        <- [daniela3]
                 /                    /
M1<---M2<---M3<-´---M4<---M5<---M6<--´           <- [origin/develop]

See that branch origin/develop remains intact

Browser other questions tagged

You are not signed in. Login or sign up in order to post.