I'm trying to move some files to a separate repository saving the history of their changes and trying to save disk space because the original repository is more than 5 GB but related to the new one takes < 50 MB.
So, I moved all files need to be moved to the new repository into a separate branch, created a new repository. Using the following git commands I was able to preserve history, but the new repository became taking the same disk space as the original one:
git remote add originalreporemote **path**
git fetch originalreporemote
git merge originalreporemote/branchwithfilestomove --allow-unrelated-histories
git remote rm originalreporemote
Looking at the new repository size I see that it takes the same size as the original one. It's excess to me since there's no scenario in the future when I need to refer to the full history of the original repository in the new one.
The history of files I moved to the new repository should take much less space.
UPD
I understand that it might be difficult to understand the issue, so you can follow the steps to reproduce it:
Let me add some steps that would allow you easily reproduce the issue:
- Create two repositories,
- Commit a text file to the master branch of repo1 so it will take several KBs,
- Create a new branch in repo1,
- Checkout back to the master branch of repo1,
- Add several large files to repo1 and commit them to the master of repo1. So now repo1 contains 2 branches - the master branch with the large files and the text file and the second branch from step #3 with the text file only,
- Try to push the second branch from the step #3 from the first repository to the second repository preserving the history of its changes (commands are above),
- I am expecting that after this operation the size of the second repository will be the same KBs as in step #3 but in fact it is the same as the size of the first repository.