为什么不能进一步减少库的大小? [英] Why won’t git further reduce the repository size?

查看:122
本文介绍了为什么不能进一步减少库的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个只有一个提交的存储库,检出大小为95M。但是,我无法获得213M以下的.git文件夹大小。但是,如果我使用相同的文件内容创建了一个新的存储库,我得到一个只有38M的.git文件夹。



有没有办法让git重建它的对象这样的方式来创建一个新的存储库的大小更符合数字?



我试过 git gc --prune =现在 - 增加 git repack -adf --window = 250 --depth = 250 来减少存储库大小。他们把这个版本库从原来的220M中解放出来。



我想git必须保留一个引用来阻止垃圾回收,但我不知道它们会在哪里。

  $ ls -R我已经删除了所有的遥控器和分支,并且在'refs'下看不到任何其他分支。 .git / refs 
.git / refs /:
标签

.git / refs /标题:
标题

.git / refs / tags:

我使用历史较长的现有存储库创建存储库。我使用 checkout --orphan 创建一个新的baseless分支,然后做了一个提交以创建一个新的提交以及存储库的状态。然后,我运行 gc 之前删除了原始分支并删除了远程。

  $ git --version 
git version 1.9.4.msysgit.0


$ div
$ $ $ $ $ > git reflog expire --all --expire = now
git gc --prune = now --aggressive

将文件夹降至27M。



我以为reflog不是问题,因为如果我运行 git reflog

code>我只看到一个条目,我的单一提交。为了回应@ torek的建议,我找到了如何删除未使用的对象一个git仓库?,这是我找到清除reflog命令的地方。


I have a repository with only one commit that has a checked out size of 95M. However, I cannot get the .git folder size below 213M. However, if I create a new repository with the same file contents, I get a .git folder of only 38M.

Is there a way to git to rebuild its objects in such a way as to get the size more in line with the figure from creating a new repository?

I tried both git gc --prune=now --aggressive and git repack -adf --window=250 --depth=250 to reduce the repository size. They brought the repository down from the original 220M.

I imagine git must be keeping a references somewhere that prevents garbage collection, but I do not know where they would be. I have removed all remotes and branches and I do not see anything other than my current branch under 'refs'

$ ls -R .git/refs
.git/refs/:
heads  tags

.git/refs/heads:
master

.git/refs/tags:

I created the repository from an existing one with longer history. I used checkout --orphan to create a new baseless branch then did a commit to create a new commit with the state of the repository. I then deleted the original branch and removed the remotes before running gc.

$ git --version
git version 1.9.4.msysgit.0

解决方案

Running:

git reflog expire --all --expire=now
git gc --prune=now --aggressive

brought the folder down to 27M. Thanks to @torek for the comment suggesting cleaning the reflog!

I had thought the reflog was not an issue because if I ran git reflog I only saw one entry, my single commit. In response to @torek's suggestion I found How to remove unused objects from a git repository? which is where I found the command for clearing the reflog.

这篇关于为什么不能进一步减少库的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆