How can I merge two branches without losing any files?

53

15

I have two branches with the following files in there:

branch a:

file_a
file_b
file_c

branch b:

file_a
file_d
file_e

I want to merge them, so that I get both files from a and b (and files that exist in both should normally be merged)! is that possbile?

reox

Posted 2011-09-27T16:26:37.543

Reputation: 915

Why don't you simply get both branches and merge them manually? – Ramhound – 2011-09-27T16:48:25.693

clone two times and copy and add? – reox – 2011-09-27T16:55:30.237

3You migt want to ask this over on StackOverflow... programmers over there might know more about this stuff. – cwheeler33 – 2011-09-27T18:32:58.923

Answers

97

this might help: http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

in your case you would do the following:

  • git checkout a (you will switch to branch a)
  • git merge b (this will merge all changes from branch b into branch a)
  • git commit -a (this will commit your changes)

take a look at above link to get the full picture.

udo

Posted 2011-09-27T16:26:37.543

Reputation: 7 661