清理 git 服务器上的大文件 [英] Clean up large files on git server

查看:13
本文介绍了清理 git 服务器上的大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人不小心将一些大型(多 GB)二进制文件提交到我的自托管 gitlab 存储库中,现在每次有人尝试从存储库中提取时,服务器都会受到严重打击.

Someone accidentally committed some large (multi-GB) binaries to my self-hosted gitlab repository, and now every time someone tries to pull from the repository the server gets hit really hard.

我尝试通过强制推送删除对文件的任何引用,但它似乎仍然会影响服务器.有没有办法强制gitlab服务器摆脱它?

I tried removing any reference to the files via force push, but it still seems to impact the server. Is there a way to force the gitlab server to get rid of it?

我阅读了一些诸如 filter-branch 之类的东西,但我不确定这会对裸仓库产生什么影响,或者我什至如何在我不再引用的提交中使用它.

I read up on some stuff like filter-branch but I'm not sure what that would do to a bare repo or how I'd even use it on a commit I no longer have a reference to.

更新:作为参考,这些类型的消息出现在 gitlab VM 的控制台上:

Update: For reference, these types of messages are appearing on the gitlab VM's console:

[ 5099.922896] Out of memory: kill process 6200 (git-upload-pack) score 1053982 or a child
[ 5099.922908] Killed process 6202 (git)
[ 5099.930796] Out of memory: kill process 6200 (git-upload-pack) score 360394 or a child
[ 5099.930807] Killed process 6203 (git)
[ 5099.938875] Out of memory: kill process 6200 (git-upload-pack) score 360394 or a child
[ 5099.938886] Killed process 6203 (git)
[ 5099.951163] Out of memory: kill process 6139 (git-upload-pack) score 324327 or a child
[ 5099.951174] Killed process 6151 (git)

推荐答案

正如 OP Karl 确认 在评论中,运行 BFG 仓库清理器(直接在裸仓库中)足以删除大型二进制文件.

As the OP Karl confirms in the comments, running BFG repo cleaner on the server side (directly in the bare repo) is enough to remove the large binaries.

如果您遵循(如Git - 删除 Blob"中所述):

If you follow that with (as mentioned in "Git - Delete a Blob"):

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

还有(git gc --aggressive vs git repack"):

But also ("git gc --aggressive vs git repack"):

git gc
git repack -Ad      # kills in-pack garbage
git prune           # kills loose garbage

你最终应该得到一个更苗条更小的裸仓库.

You should end up with a slimmer and smaller bare repo.

这篇关于清理 git 服务器上的大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆