如何减少大型存储库中的磁盘空间使用量? [英] How to reduce disk space usage in a large repository?
问题描述
我有一个拥有大约1年开发历史的git仓库,它已经是37GB了。我怎样才能以一种我将删除旧历史的方式来缩小规模?也就是说,我只需要覆盖过去2个月的历史记录,其他人可以被删除。 解决方案
:
- 从历史记录中删除大文件(,例如BFG ) 将一个repo子文件夹分割成它自己的repo
- 拆分repo历史记录从新回购HEAD的新回购开始,保留旧回收存档)。
最后一点,请参阅如何从git存储库中删除旧的历史记录?,使用类似这样的脚本(以2个月前提交的SHA1作为参数)
#!/ bin / bash
git checkout --orphan temp $ 1
git commit -m截断历史记录
git rebase - -temperature $ 1 master
git分支-D temp
#以下两个命令是可选的 - 它们可以让你的git repo保持良好状态。
git prune --progress#删除所有没有引用的对象
git gc --aggressive#积极收集垃圾;可能需要大量时间在大回购
因为它重写了历史记录,所以您需要一个 git push --force
。
由于OP推送至 git.assembla.com
(< a href =http://chat.stackoverflow.com/rooms/83378/discussion-between-rkevx21-and-vonc>见讨论),这个问题明确指出
您需要启用
- force
选项。
这是通过 Git存储库设置选项卡完成的。您必须是空间中的所有者才能看到设置标签。
I have a git repository with about 1 year of development history, and it is already 37GB. How can I minimize the size in a way where I will delete the old history? That is, I only need the history that covers the last 2 months, others can be removed.
The three main options are:
- removing large files from the history (with, for instance, BFG)
- split a repo subfolder into its own repo
- split a repo history (starting with a new repo from HEAD of new repo, keeping the old one for archive).
On the last point, see "How do I remove the old history from a git repository?", using a script like this one (with the SHA1 of the commit from 2 months ago, as a parameter)
#!/bin/bash
git checkout --orphan temp $1
git commit -m "Truncated history"
git rebase --onto temp $1 master
git branch -D temp
# The following 2 commands are optional - they keep your git repo in good shape.
git prune --progress # delete all the objects w/o references
git gc --aggressive # aggressively collect garbage; may take a lot of time on large repos
Since it rewrites the history, you will need a git push --force
.
Since the OP is pushing to git.assembla.com
(see discussion), this issue clearly states
You need to enable the
--force
option.
This is done from the Git repository Settings tab. You need to be an 'Owner' on the space to see the settings tab.
这篇关于如何减少大型存储库中的磁盘空间使用量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!