I have a repository A (the original one) having its full set of commits. At a point in time it was decided that repository A wouldn't be used anymore and a new clean repository B was created from scratch putting all repo A's contents using copy + paste (not by merging A's contents into the clean B, so that to keep commits history) in it. What I want to achieve now is to glue both repositories' commits and history (it is very important that history is glued) in a third new clean repository C. The final aim is that repository C should contain all changes from both source repos A and B in chronological order as if repository B wasn't created at all e.g. as if work has proceeded in repository A.
So the current situation is:
repo A: commit A1 > commit A2 > commit A3 > ... > commit An
repo B: commit B1 (= A1 + A2 + A3 + ... + An) > commit B2 (= commit An+1) > ... > commit Bk
Tried the following approaches:
git remote add -f A <repo_A_url>
git merge A/master
git remote add -f B <repo_B_url>
git merge B/master
Then resolved conflicts. Partially worked since history was messed up somehow.
Then tried I think the cleanest approach - merge only repo A into repo C and then cherry pick repo B's commits ranging from B2 ... Bk. It works but cherry picking merge commits slows down the merge process.
I could be duplicating a topic and please tell me if I do, since crawled through many threads and mostly seen how to add two repos to a third one by positioning them in different folders in the final repo which is not the case. If you could share the most suitable, sematically correct and git-friendly approach possible.
Big thanks.
You can cherry pick a range of commit by a single commit.
Or, you can rebase. Go to C repo
masterbranch. You can checkout a new banch (say,rebase) then Merge B/master and rebase it ontoA/masterIf all histories looks ok then replace
masterbyrebasebranch.