In my previous job, I need to do lost of code merging and comparing work. The tool I used is Araxis Merge.
Well, it's not a freeware. I know there is some similar freewares, but seems not so powerfull.
Anyway, have some looks on this tool.
Two-way comparison and merging:
Three-way comparison and merging:
List price for a single standard license is US$ 129, I think the price is a little expensive.
Anyone who has wanna have a try can go to here
You are welcome to introduce some freeware which you would like to recommend others to try it.