即使文件未登台,git也会占用空间 [英] git use up space even when file is unstaged
本文介绍了即使文件未登台,git也会占用空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用git-lfs
将较大的二进制文件添加到我的git存储库中,但是失败了:
I wanted to use git-lfs
to add a large binary into my git repository but that failed:
$ git add large-file.tar.xz
所以我取消了文件的存储
So I unstage the file
$ git checkout -- large-file.tar.xz
$ git status
On branch lfs
nothing to commit, working tree clean
但是git仍然会用完大文件的磁盘空间.
But the git still use up the disk space for the large file.
$ du -sh .git
101M .git
回收空间
我尝试使用 BFG回购清洁器除去斑点,但没有任何操作被发现. (是的,BFG只扫描现有的提交,但是我很绝望)
Reclaiming the space
I tried using the BFG repo cleaner to remove the blob, but nothing is found. (Yes, BFG only scan for existing commits, but I was desperate)
$ bfg --strip-blobs-bigger-than 10M .
Using repo :path/to/project
Scanning packfile for large blobs: 725
Scanning packfile for large blobs completed in 31 ms.
Warning : no large blobs matching criteria found in packfiles - does the repo need to be packed?
git gc
不能正常工作
$git reflog expire --expire=now --all && git gc --prune=now --aggressive
$ du -sh .git
101M .git
推荐答案
不要忘记删除任何bfg或filter-branch操作留下的原始对象.
Don't forget to delete the original objects left as a backup by any bfg or filter-branch operation.
rm -Rf .git/refs/original
然后您可以修剪其余部分:
Then you can prune the rest:
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
git repack -Ad # kills in-pack garbage
git prune # kills loose garbage
这篇关于即使文件未登台,git也会占用空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文