提交错误的内容到Git

6

大约700次提交前(>30天),我不小心将ThirdParty/mapper/Songbird_1.2.0-1146_windows-i686-msvc8.exe(类似iTunes下载的文件)保存在了本地Git存储库中,但没有注意到这一点,该文件也被推送到远程托管的git存储库。最近我注意到该存储库超过了200mb,而我预计的大小应该是20mb左右。

我已经按照以下说明进行操作:http://github.com/guides/completely-remove-a-file-from-all-revisions

并且运行了git gc --aggressive --prune命令,但本地目录仍超过200mb。在我可以整理远程存储库之前,我需要整理本地存储库。我的情况是否有特殊之处(即大文件,很久以前的提交)。如何完全删除此文件并将目录大小降至正确大小?

注意:为避免迁移,我认为这更适合于StackOverflow,因为Git目前主要是本地开发人员工具,由社区支持,并不属于任何主流发行版或系统管理员的预期,即目前开发人员最了解git管理员。

1个回答

3

我曾在“git:缩小Subversion导入”中写过一个类似的问题。

The git filter-branch manpage has a checklist for shrinking a repository that recommends running filter-branch and then cloning to leave behind the cruft.

Cloning with a filesystem path makes hardlinks, so use a URL:

$ git clone file:///home/gbacon/src/dBTools.git

Even after doing this, some big unnamed blobs had survived the clone. Thanks to #git on freenode for the suggestion to excise the reflog:

$ git reflog expire --verbose --expire=0 --all
$ git gc --prune=0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接