0

I have a branch A and I want to merge branch B into A.

when I merge branch B into A it only merges the last commit do to branch B into A, I want to merge the entire branch, I've tried rebasing and following every answer on this site but nothing seems to work.

Shaun Wild
  • 1,237
  • 3
  • 17
  • 34
  • 1
    please check what commits of B aren't in A yet: `git log B --not A`. – user3159253 Dec 08 '15 at 15:21
  • 1
    I guess there'll be exactly one unmerged commit. – user3159253 Dec 08 '15 at 15:22
  • Nothing is returned by that command, according to the merge the branches have no differences eventhough pulling A returns different code to when I pull B – Shaun Wild Dec 08 '15 at 15:22
  • 1
    Then _all_ commits from B are already in A, aren't they? You may also check `git log A --not B` to see commits in A that aren't in B, then you may understand better why you get "strange" results on merge. – user3159253 Dec 08 '15 at 15:29
  • Git doesn't exactly "pull branches". In git, `pull` is just a convenience script that runs `git fetch` and then `git merge`. It's the `git fetch` step that brings in remote work. Git uses seemingly-deliberately-confusing terminology here: read up on the definition of a "remote", a "remote-tracking branch": e.g., http://stackoverflow.com/q/25068543/1256452 and http://stackoverflow.com/a/33536975/1256452 – torek Dec 08 '15 at 19:48

1 Answers1

1

In git, a branch is basically a pointer on a commit. So your branch B is a pointer to the last commit of the branch B.

When you do git merge branchB on branch A, git is going to select this last commit plus all its ancestors that were not already on branch A. So the merge is already "merging the entire branch".

You can see it, if the merge succeeded, by doing afterwards git diff HEAD^1 HEAD. This should show you all the modifications applied from branch B.

What may be confusing you is the git log display : it will show a merge commit whose parents are both tip of branch A and tip of branch B. This is actually what a git merge is about : trying to create a commit from two different parents.

oailloud
  • 363
  • 1
  • 2
  • 7
  • But when I merge B into A I would then assume that all of the files on B should be present on A but they're not. – Shaun Wild Dec 08 '15 at 15:32
  • 1
    It's pretty strange, they should. Are you sure that : 1) the merge succeeded ? 2) the new files were commited on branch B ? Aren't they still untracked ? – oailloud Dec 08 '15 at 15:51
  • I can't comment on your question... Not sure what you mean by "when I pull B". I thought maybe you are getting mixed up between a remote branch and its local version (`git branch -avv` to check it). – oailloud Dec 08 '15 at 16:57
  • I've literally been using git for a week so I have very little insight into how git works. – Shaun Wild Dec 08 '15 at 17:10