tags:

views:

63

answers:

2

Sorry if this is a stupid question with just a yes/no answer, but if I understand correctly, in git a branch is just a pointer to a commit. Doesn't this imply that once you've merged two branches, git doesn't know which one pointed to which set of commits?

Before

A---B---C---D---E    <- X
 \                
  1----2----3----4   <- Y

After

A---B---C---D---E--M  <-X & Y
 \                /
  1----2----3----4
+9  A: 

If I recall correctly you merge a branch into another one, like feature1 into master, so master now points to merge-commit but feature1 still points to where it pointed before.

Edit by Jefromi: This is correct. The pictures should look like this:

git checkout branch X

    A---B---C---D---E   branchX (HEAD)
     \                
      1----2----3----4   branchY

git merge branchY

    A---B---C---D---E--M  branchX (HEAD)
     \                /
      1----2----3----4  branchY
Arkaitz Jimenez
Yup - you merge one branch into another. So whatever branch you were on when you issued the merge command will be the current branch after the merge.
bergyman
@Arkaitz, @Jefromi ok, so what happens if I do a rebase then merge, as suggested here (http://stackoverflow.com/questions/804115/git-rebase-vs-git-merge/804178#804178)?
Benjol
+1  A: 

Merging branches doesn't actually merge the ref of the other branch; it merges the content of the other branch into the current one.

hasen j