如何减少大型存储库中的磁盘 space 使用率?
How to reduce disk space usage in a large repository?
我有一个git 的仓库,大约有1年的开发历史,已经有37GB了。如何以删除旧历史记录的方式最小化大小?也就是说,我只需要最近2个月的历史记录,其他的可以去掉。
三个主要选项是:
- 正在从历史记录中删除大文件(with, for instance, BFG)
- split a repo subfolder into its own repo
- 拆分一个回购历史(从新回购的 HEAD 开始一个新的回购,保留旧的用于存档)。
关于最后一点,请参阅“How do I remove the old history from a git repository?”,使用这样的脚本(使用 2 个月前提交的 SHA1 作为参数)
#!/bin/bash
git checkout --orphan temp
git commit -m "Truncated history"
git rebase --onto temp 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
因为它改写了历史,所以你需要一个git push --force
。
由于 OP 正在推送到 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.
我有一个git 的仓库,大约有1年的开发历史,已经有37GB了。如何以删除旧历史记录的方式最小化大小?也就是说,我只需要最近2个月的历史记录,其他的可以去掉。
三个主要选项是:
- 正在从历史记录中删除大文件(with, for instance, BFG)
- split a repo subfolder into its own repo
- 拆分一个回购历史(从新回购的 HEAD 开始一个新的回购,保留旧的用于存档)。
关于最后一点,请参阅“How do I remove the old history from a git repository?”,使用这样的脚本(使用 2 个月前提交的 SHA1 作为参数)
#!/bin/bash
git checkout --orphan temp
git commit -m "Truncated history"
git rebase --onto temp 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
因为它改写了历史,所以你需要一个git push --force
。
由于 OP 正在推送到 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.