merge – Merging two git repositories as different versions – Education Career Blog

I have two git repositories, like this:

  • proj1
  • proj2

proj1 has a tag v1.0.0 and proj2 has tags v2.0.0 and v2.1.0. Now I would like to merge proj1 (the v1.0.0 tag in particular) into proj2 as if it was an earlier version of proj2, so that I have the tags v1.0.0, v2.0.0 and v2.1.0. I’m also fine if I have to merge proj2 into proj1 or merge both into a new repository, as long as I get all the tags and the combined history.

There is a lot of people asking similar questions, like the following, but none seem to have my particular problem – adding two repositories as different versions.
Merging two Git repositories

Is that possible?


It is possible. Use git remote add proj2 file:///path/to/proj2 within proj1. Then git fetch proj2. Now all the commits in proj2 are visible within proj1, and you can use branch merging, tagging, etc. to splice things together in one repository.

If this is a repository used by other people you might want to backup your .git directory before starting.

Leave a Comment