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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…