How to merge unversioned code into Git repository?
-
21-12-2019 - |
Question
So a friend worked on a bunch of code that he never versioned, and is handing it off to me. He initially gave me version A, even though he had a more recent version B available. I put A into a git repository (on say Visual Studio Team Services), and then made some commits, resulting in version C. Now he has put up version B in a git repository (on say Bitbucket). How can I compare versions C and B, and merge all diffs between (B,A) and (C,A) to get one final version D which has both his updates and mine? Keep in mind, the repos on Bitbucket and TFS (versions B and C respectively) have no common git commits, although they both come off the same base version A.
I can see a couple of ways of doing this, not sure of the cons of each though: 1) Add Bitbucket version B as an upstream to my TFS version C, and fetch upstream/master, then do a git diff. 2) Copy the files from version B into the directory that holds version C, and then commit them as if I changed the files manually. 3) Something else entirely, like rebase.
My understanding of git is very basic so please explain like I'm 5 (well, not really, but you know what I mean).
Note: It is ok to have all changes made from A to B in one commit in the final repo history, but would be nice to preserve the individual commits between A and C.
Also, from version A to version B, the friend has not maintained directory structure, he has moved all the contents to a sub-directory of the root. So if version A had file a.txt, version B has file TRUNK/a.txt.
Solution
Simply:
checkout
A
make a new branch from
A
(from "Git version control and Team Foundation Build")copy
B
in itadd and commit:
(from "Create, Connect, and Publish using Visual Studio with Git")merge that branch in your main branch which represents
C
- resolve conflicts: