I need to merge two git repositories into one new repository without losing the history and preserve the feature branches and tags.
This seems like a pretty common question which already has been solved many times (e.g. https://github.com/unravelin/tomono or Merge two Git repositories without breaking file history).
But what none of the solutions managed to solve is, that i can jump back in time and view all files from a specified commit, where both subdirs are present.
So I wonder if something like this is even possible with git.
This is my current setup: Two repositories which were seperatly developed:
These are both cloned and bundled into a rpm by our build-system (including some config and data-directories)
Now I want to migrate both repositories into one "monorepo" where I could also store the config, and other basic required subdirs.
If I use one of the many "merge x repos to a single repo"-solutions i will end up with one of two states when looking at the directory-tree of that commit:
This also make the tags pretty much useless. I would like to have both app and lib visible at any commit.
A long time ago, when migrating from SVN to git I managed something like this by reading both histories and "replaying" the commits as if the subdirectories where always there.
Is there a way for this particular problem, or do I realy have to live with the lost tags and "incomplete" history?
TLDR; After another full day spent on that topic, I settled with the solution with the least downsides. A combination of subtree-merge-strategy from https://stackoverflow.com/a/14470212/11126816 and git filter-branch from https://stackoverflow.com/a/43340503/11126816
Maybe the following tools will help others: