使用 git filter-branch 然后 git push --force 清除大文件后,远程(Gitlab)上的 Git 存储库大小仍然很大

标签 git gitlab git-filter-branch

我已按照 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/

相关文章:

windows - Git:查找大包文件中的最大文件

bash - 如何在文件夹模式上使用 git filter-branch

git - 检查提交是否 merge 到另一个分支,如果是, merge 提交是什么?

kubernetes - 如果发布了较大的json,则用于自动审查应用程序(gitlab-managed-apps)的NGINX入口会非常慢

docker - 带有Docker的Gitlab不会更新

windows - git (ssh_exchange_identification) 连接由对等方重置(windows、gitlab)

git - 使用过滤器分支删除 Git LFS? (无法将未更改的文件重新添加到索引。)

git - 如何移动 git 存储库的根目录?

git - Jenkins 管道环境变量

git - 我如何让两个 "streams of development"(分支?)相互跟踪,同时以特定方式保持不同?