减少git存储库大小 [英] Reduce git repository size

查看:84
本文介绍了减少git存储库大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着寻找一个关于减少回购大小的好教程,但没有发现。我如何减少我的回购大小...它大约是10 MB,但是Heroku只允许50 MB,并且我没有接近完成开发我的应用程序的地方。



我已经将通常的嫌疑犯(日志,供应商,文档等)添加到.gitignore。尽管我最近只添加了.gitignore。



有什么建议吗?

解决方案

git gc --aggressive 是强制修剪过程发生的一种方法(可以肯定: git gc --aggressive --prune = now ) 。你必须其他命令的清洁回购也是如此。不要忘了,有时候 git gc 就可以增加repo的大小

它也可以在过滤器后使用-branch ,标记一些要从历史中删除的目录(进一步增加空间);请参阅此处。但这意味着没有人从你的公共回购中撤出。 filter-branch 可以在 .git / refs / original 中保留备份引用,这样该目录也可以被清除。 / p>

最后,如在本提到评论这个问题;清理reflog有助于:

  git reflog expire --all --expire = now 
git gc --prune = now --aggressive

更完整且可能危险的解决方案是从git仓库中删除未使用的对象


I tried looking for a good tutorial on reducing repo size, but found none. How do I reduce my repo size...it's about 10 MB, but the thing is Heroku only allows 50 MB and I'm no where near finished developing my app.

I added the usual suspects (log, vendor, doc etc) to .gitignore already. Although I only added .gitignore recently.

Any suggestions?

解决方案

git gc --aggressive is one way to force the prune process to take place (to be sure: git gc --aggressive --prune=now). You have other commands to clean the repo too. Don't forget though, sometimes git gc alone can increase the size of the repo!

It can be also used after a filter-branch, to mark some directories to be removed from the history (with a further gain of space); see here. But that means nobody is pulling from your public repo. filter-branch can keep backup refs in .git/refs/original, so that directory can be cleaned too.

Finally, as mentioned in this comment and this question; cleaning the reflog can help:

git reflog expire --all --expire=now
git gc --prune=now --aggressive

An even more complete, and possibly dangerous, solution is to remove unused objects from a git repository

这篇关于减少git存储库大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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