git git大包文件,删除和重写?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24693360/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:12:30  来源:igfitidea点击:

git large pack file, delete and rewrite?

git

提问by agrT

I have a relatively small git repository containing a standard Wordpress installation. However, I accidentally added a "concept" folder in the repository which contains many large psdfiles.

我有一个相对较小的 git 存储库,其中包含标准的 Wordpress 安装。但是,我不小心在包含许多大psd文件的存储库中添加了一个“概念”文件夹。

The problem is that now, after 50 commits, git has created a "pack" file, which is 1,3 GB.

问题是现在,在 50 次提交之后,git 创建了一个 1.3 GB 的“pack”文件。

To downsize the pack folder I tried to remove my "concept" folder via:

为了缩小包文件夹的大小,我尝试通过以下方式删除我的“概念”文件夹:

git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch DIRECTORY/' --prune-empty --tag-name-filter cat -- --all

and afterwards

然后

git gc --aggressive --prune

After the execution of these commands, my "concept" folder was deleted from the file system and from all commits but the pack file is still exactly 1,3 GB

执行这些命令后,我的“概念”文件夹从文件系统和所有提交中删除,但包文件仍然正好是 1,3 GB

Is there anything else I can do to reduce the size of the pack folder?

我还能做些什么来减小包文件夹的大小?

回答by VonC

I mentioned before that a git gcalone can actually increase the size of the repo).

我之前提到过,一个git gc人实际上可以增加 repo 的大小)

The commands I was listing were:

我列出的命令是:

# remove the temporary history git-filter-branch otherwise leaves behind for a long time
rm -rf .git/refs/original/ && git reflog expire --all &&  git gc --aggressive --prune=now

If that doesn't work, check out the BFG tool.

如果这不起作用,请查看BFG 工具

You will find an even more complete gc in "How to remove unreferenced blobs from my git repo"

你会发现在“一个更完整的GC如何从我的混帐回购协议中删除未引用的斑点

This articlesuggests a similar approach:

这篇文章提出了一种类似的方法:

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git fsck --full --unreachable
git repack -A -d
git gc --aggressive --prune=now