我已按照 Gitlab 文档中有关“使用 Git 减小存储库大小”的说明进行操作
“通过从历史记录中清除大文件:
https://docs.gitlab.com/ee/user/project/repository/reducing_the_repo_size_using_git.html
我引用的说明如下:
git checkout master
git filter-branch --force --tree-filter 'rm -f path/to/big_file.mpg' HEAD
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push --force origin master
然后我删除了本地存储库,并再次从远程克隆,大小已减小,克隆后从 600mb 减少到 90mb,但在 Gitlab 存储库页面上仍然显示大小为 600mb。
有谁知道我为什么会看到这种行为以及如何解决它?
最佳答案
这是我的一个错误,没有彻底阅读文档,我引用了 Gitlab 文档:
Note that even with that method, until git gc runs on the GitLab side, the "removed" commits and blobs will still be around. And if a commit was ever included in an MR, or if a build was run for a commit, or if a user commented on it, it will be kept around too. So, in these cases the size will not decrease.
关于使用 git filter-branch 然后 git push --force 清除大文件后,远程(Gitlab)上的 Git 存储库大小仍然很大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51213156/