+ 2

how can i merge two branches with different functionality in git.

i have two branches a & b. a contains some functions now b also contains some functions but they contains old code of functions of a as well. now when i will merge these two branch how will i define which functions i want & which i don't

6th Oct 2017, 3:02 AM
shobhit
shobhit - avatar
2 Answers
+ 15
If branch A and B both modified the same code, it will generate "Conflict" after merging, now you type "git status", it will show the file it cannot be merged automatically(with red color), you need to merge manually by yourself, the file which have conflict will contain some "tag" like this: <<<<<<< HEAD int a = 10; ======= int a = 5; >>>>>>> master You must choose which you want and delete those tags, then "git add ." and "git commit" to finish merging.
19th Oct 2017, 3:09 AM
Corey
Corey - avatar
+ 3
git has pretty good documentation. If the code still has enough of the original base code (from before it was branched) then it is quite good at working out the changes. It will take all the newest parts it can. If git can't tell which version of a piece of code to use (because it's been changed in both branches), then git will as ask which version should be used.
6th Oct 2017, 8:11 AM
Jared Bird
Jared Bird - avatar