GIT: how to use one database of blobs for two repos
I have a huge GIT repo that contains the history of a certain folder, and another (second) folder that contains ~50% of the same (identical) files as the first one and another ~50% of its own files not present in the first folder.
For a number of reasons I want GIT to use the blobs in the first folder‘s
.git dir for managing the history of the second folder. The repositories themselves should be (or at least appear) independent. How do I achieve this?
One Solution collect form web for “GIT: how to use one database of blobs for two repos”
Git can do this via
objects/info/alternates. Documentation can also be found searching for
git clone --reference.
You do have to be careful how you set this up as you do not want garbage collection in one repo to remove objects that the other repo needs.
Wait a second, are the two folders in the same repo, or in different repos? My answer was for if they are in different repos. If they are in the same repo, git will just handle this automatically because the files’ hashes will be the same so they will automatically be saved in the same blob.