git – How does the merge work?

Question:

I created another branch as a backup and merge it, suppose I'm on the daniela3 branch :

git merge origin/develop

Will only my daniela3 branch be affected or origin/develop too? I mean, will I be joining what has in origin/develop -> daniela3 and origin/develop remains without my changes OR are both of them updated?

Answer:

Only the repository you are currently in is updated (in this case it must be daniela3 if I understand daniela3 ). If you want another repository to be updated (not that it seems to be your case) you will have to push to it.

So the merge is always local. When you want to update another repository you bring its content into your current local repository, merge and send your repository content back to the original, possibly remote, repository.

merge only acts on the current repository considering the differences for the specific repository that is connected. Any other branches are not considered. If there is a need to consider other branches , they must be merged into the proper repository beforehand.

Scroll to Top