为什么我的.git文件很大? [英] Why is my .git file huge?

查看:1435
本文介绍了为什么我的.git文件很大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶然地在git目录中添加并提交了一些非常大的(100MB +)PSD文件。当他们在目录中时,我对这些文件进行了一系列编辑,但后来他们意识到他们不应该在那里并将它们从目录中移除。



然后我跑:

  git add --all&& git commit -m删除大psds

我的目录中的文件现在加起来不到一个打几MB,除了.git文件本身,但是,它是700MB +。



这是怎么回事?它是否保留已删除的.PSD文件的旧版本?这是否意味着git不会清除删除文件所获得的空间?我怎样才能完全忘记这些文件,这样我就可以将.git文件的大小还原下来? 你的。 git文件夹非常大,因为PSD文件仍然存在于存储库中。要删除它们,您需要使用 git filter-branch 修改历史记录。 此处说明如何使用此功能命令。之后,您需要清理存储库。



我创建了一个脚本来帮助这项工作。如果你想使用它,你可以从 github 下载它。欢迎任何评论。


I accidentally added and committed some very large (100MB+) PSD files in a git directory. I made a bunch of edits to those files while they were in the directory, but then realized they shouldn't be there and removed them from the directory.

I then ran:

git add --all && git commit -m "Removed large psds"

The files in my directory now add up to less than a dozen MB, except for the .git file itself however, which is 700MB+.

What is going on here? Is it retaining old versions of the removed .PSD files? Does that mean git doesn't ever clear out the space gained from deleting files? How do I have it forget about those files completely so that I can bring the .git file size back down?

解决方案

Your .git folder is really big because the PSDs files are still present in the repository. To remove them, you need to modify the history using git filter-branch. Here explains how to use this command. After, you will need to clean the repository.

I created a script to help this job. If you want to use it, you can download it from github. Any comments are welcome.

这篇关于为什么我的.git文件很大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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