0

Possible Duplicate:
How do you merge two git repositories?

I have an existing git repository A.

For another project, project B, my colleague has gone ahead and created a new git repository. We've added a bunch of code to this repository so naturally its structure does not resemble repository A.

Now it turns out that the we'd like to use A in the project B. Ideally we'd like to fork A into the repository that already exists for B under a subdirectory of B as to not interfere with the work that's already there. Naturally we'd like to preserve the history of A (ie not just copy a bunch of source over).

We plan to then modify the cloned/forked A extensively for project B's specific needs (this is a throw-away demo).

What is the best way to do this? Can clone be used to acheive this? Or maybe I could clone A, move stuff to where I want it to go, and then attempt to merge it into B? Can you merge two repositories that have never had a shared history?

Community
  • 1
  • 1
Doug T.
  • 59,839
  • 22
  • 131
  • 193
  • Sounds like you want [submodules](http://git-scm.com/book/en/Git-Tools-Submodules). – Fred Foo Dec 22 '12 at 17:57
  • @larsmans submodules are for referring to libraries/externals no? We need to modify the cloned version of A extensively for project B. We just want a clone/fork of A to live in B's repository. – Doug T. Dec 22 '12 at 17:59
  • 1
    That's true. You're not going to merge the changes to the fork of A into the original A? Then [this question](http://stackoverflow.com/q/1425892/166749) on merging repos might be of interest. – Fred Foo Dec 22 '12 at 18:02
  • @larsmans yeah that's exactly what I'm looking for (subtree merge). Voting to close my question as dup of that. – Doug T. Dec 22 '12 at 18:10

0 Answers0