Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git merging one branch into another is a two way merge?

My git repo looks like this:

         _ branch_a         / master /         \_ branch_b 

Now I want to merge branch_b into branch_a, not either branch into master.

So, I did

git checkout branch_a git merge branch_b 

And git went and found a couple of conflicts.

When I do git mergetool using meld what I get on the console is

 {local}: modified file  {remote}: modified file 

and a window showing only LOCAL and REMOTE.

What I want to know is:

  1. Why isn't the shared base of what was in master shown?

  2. Between LOCAL and REMOTE, which one am I supposed to edit?

like image 779
EMiller Avatar asked Mar 06 '13 21:03

EMiller


People also ask

Is git merge two way?

Git merging combines sequences of commits into one unified history of commits. There are two main ways Git will merge: Fast Forward and Three way. Git can automatically merge commits unless there are changes that conflict in both commit sequences.

What happens when you merge branches in git?

When you perform a merge, you effectively merge one branch into another—typically a feature branch or bug fix branch into a main branch such as master or develop. Not only will the code changes get merged in, but also all the commits that went into the feature branch.

Does merge change both branches?

No, merging does only affect one branch.


1 Answers

If you merge a branch A into a branch B the conflicts that you get come from the difference between both branches and not from the difference with master. executing git diff in A or B will give you however the diff with mastere since it is the ancestor

Normally the local branch should be the one you are merging into and the remote the one you want to merge. Anyway in your computer you will only have one copy of the file so just modify it

like image 168
iberbeu Avatar answered Oct 06 '22 14:10

iberbeu