spyro95
spyro95

Reputation: 146

Merge 2 different git repositories with nearly exact content

Right now I've two different repositories. Repo 1: only the "core" and some "sys" modules. Repo 2: Got also "core", "sys" and also a lot of other stuff. The problem is that the second repo isn't tracking or uploading any changes of core or sys modules and I've made a lot of changes in there. Core and sys didn't have had the same stage as core and sys had before I made these changes.

Now I wan't to sync "core" and "sys" from repo 2 with repo 1 and I does not have any idea of a slight solution.

Upvotes: 0

Views: 36

Answers (1)

Frediano Ziglio
Frediano Ziglio

Reputation: 310

Quick answer: git remote add, fetch, merge.

Long one following. Even if the repository are completely different (without a common ancestor) you can have the content of 2 repository in one. On one repository (say repository A) use git remote add to add the second repository (say repository B). Still in first repository (A) fetch the content of the second with git fetch repository_B. What you get is a repository with the content of both. You now can merge them. Say that you are in master, you can merge other repository master with a git merge repository_B/master. Now you got a new commit with all content that you can push.

If you have lot of conflicts is better to attempt to make the 2 content more similar using git diff and incrementally update one or the other to reduce the differences. This could involve for instance git mv if the directory paths are different.

Upvotes: 1

Related Questions