gpt4 book ai didi

git - 减少 git 存储库大小

转载 作者:IT王子 更新时间:2023-10-29 01:13:45 26 4
gpt4 key购买 nike

我试图寻找一个关于减少存储库大小的好教程,但没有找到。我如何减少我的存储库大小...大约 10 MB,但问题是 Heroku 只允许 50 MB,而且我还没有完成我的应用程序开发。

我已经将常见的可疑对象(日志、供应商、文档等)添加到 .gitignore。虽然我最近才添加 .gitignore。

有什么建议吗?

最佳答案

2021 年 2 月更新,十一年后:新 git maintenance command ( man page ) 应该取代 git gccan be scheduled .


原文:git gc --aggressive是强制执行修剪过程的一种方法(可以肯定的是:git gc --aggressive --prune=now)。你有other commands也清理 repo 协议(protocol)。不过别忘了,有时 git gc 一个人就可以 increase the size of the repo !

它也可以用在filter-branch之后,标记一些要从历史中删除的目录(进一步增加空间);见 here .但这意味着没有人从您的公共(public) repo 中提取。 filter-branch can keep backup refs in .git/refs/original , 因此该目录也可以被清理。

最后提到in this commentthis question ;清理 reflog 可以帮助:

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

一个更完整但可能更危险的解决方案是 to remove unused objects from a git repository

关于git - 减少 git 存储库大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2116778/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com