1

I have two git repos, lets call them A and B. I want B to be the same as A so I would like to copy A switch the repo it thinks its in, then commit and push the changes to B.

B already has code that is fairly similar to A, and I would like to keep the history. A has hidden files that need to be copied (less .git and .gitignore)

Seth McClaine
  • 9,142
  • 6
  • 38
  • 64
  • 4
    Have you tried replacing the .git folder? It contains the repository information (e.g. the history). If you want to preserve the history of both repositories, you need to make a subtree merge. I've never done it with the whole repo (normally with a subdirectory of a repo only) but I can imagine that this could work. The new repository then somewhat has two starting revisions (that of A and B). But I can imagine it is possible to bring it together. Take care if those two repositories share branch and tag names. https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging – hakre Jun 14 '17 at 16:47
  • 2
    Possible duplicate of [How to import existing Git repository into another?](https://stackoverflow.com/questions/1683531/how-to-import-existing-git-repository-into-another) – hakre Jun 14 '17 at 16:56
  • I'm not sure I understood the question, but it seems to me that you can just have a single _local_ repo and two _origin_ repos. You just check out from a repo and push on the other – Phugo Jun 14 '17 at 17:54
  • Thank you @hakre – Seth McClaine Jun 14 '17 at 21:17

0 Answers0