I want to combine 2 git repositories, and I want to preserve file history but I do not want to preserve commit history. In other words, I want to keep the changes over time, but I don't care about the SHA checksums. I will not need the old repositories after the merge.
The answers to the following questions do not help me, because I always end up with a repo with two roots and separate commit history:
What I want to do, is the exact opposite of Detach (move) subdirectory into separate Git repository, where git subtree
is used to filter out all the commits that affect the files in a subdirectory.
My two repositories have some overlapping directory structure, but no overlapping files (except for .gitignore
and .gitattributes
) and I want to merge them at the root of a repository.
Both repositories have tags that have a slightly different naming scheme, but point to a specific release. For example repoA has tags A-1.0.0, A-1.0.1 and repoB has tags B-1.0.0, B-1.0.1. I don't really care about the commits between the tags, different branches or one branch, but at the tags there must be a merge point somehow.
The only idea I can come up with so far that may work (I have tried everything I could find with subtrees and merges):
- add repoB as a remote
- add a branch in repoA (mergeB) at a point in history before tag A-1.0.0
- cherry-pick the commits from repoB up to tag B-1.0.0 onto the branch mergeB
- checkout A-1.0.0
- merge branch mergeB
- cherry-pick every commit from repoA from old tag A-1.0.0+1 up to the old HEAD
- branch again
- repeat steps 3-7 for the next tags
- when everything is done, do a rebase (maybe interactive) to clean up stuff
This sounds like a lot of manual work, is there a better way to do this?