3

In my git history there is a 1k line file, call it main1.cpp. In a massive violation of DRY it was forked (copied to another name and added to version control) into a main2.cpp, about 30% of which has since diverged from main1.cpp.

Many changes to main1.cpp have been made concurrently by another developer. Is there a way to use git's merge facilities to merge the changes, or would it be better to manually fire up a three-way merge tool and do a 3-way merge, ignoring the two histories that diverged the files?

Andrew Wagner
  • 22,677
  • 21
  • 86
  • 100
  • What do you mean that `main1.cpp` was *"forked"* to `main2.cpp`? Do you mean it was just copied with a different name in the same repository? – Thomas Stringer Sep 16 '15 at 12:59
  • Yes, but I thought that was clear in the body of my question. – Andrew Wagner Sep 16 '15 at 13:03
  • 1
    *"Fork"* has a very different meaning then what you intended it to regarding git. This merge isn't a git operation, and wouldn't really pertain here. Your best bet (and only way, I believe) would be the three way merge. Take a look at this: http://stackoverflow.com/questions/9122948/run-git-merge-algorithm-on-two-individual-files – Thomas Stringer Sep 16 '15 at 13:11
  • I actually did not know about "git merge-file." In easy merge cases that might be handier than firing up a full merge tool, i.e. meld. It doesn't use any extra history information, but maybe that's not used normally either... – Andrew Wagner Sep 16 '15 at 13:47

0 Answers0