[英]git filter-branch doesn't delete all files i want
I'm trying to clean up a git repository of latex code that contains the generated pdf files, because these files have caused the repo to balloon up to a size of 300mb.我正在尝试清理 latex 代码的 git 存储库,其中包含生成的 pdf 文件,因为这些文件导致 repo 膨胀到大小。30
Adapting a bit from the answer here How to remove file from Git history?从这里的答案中调整一下如何从 Git 历史记录中删除文件? .
. I tried the following command:
我尝试了以下命令:
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch *.pdf' HEAD
This reduced the size a little, but not as much as i'd hoped.这减少了一点尺寸,但没有我希望的那么多。 When I then try the script found in the answer to this question: How to find/identify large commits in git history?
然后,当我尝试在此问题的答案中找到的脚本时: 如何在 git 历史记录中查找/识别大型提交? , to find which files contribute to the size, it still shows several pdf files.
,要查找哪些文件对大小有影响,它仍然显示几个 pdf 文件。 However, if i try the script found in this question: Which commit has this blob?
但是,如果我尝试在这个问题中找到的脚本: Which commit has this blob? , it cannot find any commit that contains the file.
,它找不到任何包含该文件的提交。
I have removed all branches except the local branch.我已经删除了除本地分支之外的所有分支。 I have not pushed the changes to the remote.
我没有将更改推送到遥控器。
Is there any reason these files would still persist in the history somewhere?这些文件是否有任何理由仍然存在于某个地方的历史记录中? What other things can I try?
我还可以尝试哪些其他事情?
You may have blobs still present just because the garbage collector didn't collect them.您可能仍然存在 blob,因为垃圾收集器没有收集它们。
Try cloning your local repo, and check the size of the .git/
directory in that new clone:尝试克隆本地存储库,并检查新克隆中
.git/
目录的大小:
git clone myrepodir myclone
cd myclone
du -sh .git
# you can then remove that clone :
cd ..
rm -rf myclone
This will be a more acurate view of how much data would be pushed or cloned.这将更准确地了解将推送或克隆多少数据。
If you are 100% positive the content after your filter-branch
action is the content you want to keep, and if you don't mind loosing your reflog (no more undos, drops all your stashes): you can run如果您 100% 肯定您的
filter-branch
操作后的内容就是您要保留的内容,并且如果您不介意丢失 reflog(不再撤消,删除所有存储):您可以运行
git gc --aggressive --prune=now
See also git help gc
for more details on what could be retained on your disk.另请参阅
git help gc
以了解有关可以保留在磁盘上的内容的更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.