6

So I'm using git on a personal server and I had an old repo that I needed to update. I removed a bunch of old files and committed and pushed the change. I'm using a web UI for it on my server (Gitlist). When I use this GUI to download the repo as a zip file, it comes out to the correct size, about 41MB. However, when I clone the repo, it comes out to something closer to a gig due to the size of one of the ./git/objects/pack files is about 900MB.

Why is the repo so large when it really should be much smaller?

Febble
  • 205
  • 2
  • 7
  • http://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big – Doon Jul 02 '14 at 19:36
  • @Doon I think the difference between that question and this one is that the person asking that question seems to understand that git clone copies the full history of the repository, whereas the OP of this question doesn't. – Ajedi32 Jul 02 '14 at 19:52
  • See also http://stackoverflow.com/questions/2164581/remove-file-from-git-repository-history, and http://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository?rq=1 – Ajedi32 Jul 02 '14 at 19:53
  • yeah I wasn't 100% sure what OP was asking – Doon Jul 02 '14 at 19:59
  • I wasn't aware that the clone keeps a local history, thanks for the help – Febble Jul 02 '14 at 20:05

1 Answers1

6

Pushing a commit which removes files doesn't lake the git repo smaller.

You need to remove those files across the history of the git repo in order for it size to shrink.
This is typically done with a combination of git filter-branch and git gc --aggressive --prune=now: see "Reduce git repository size".
(Don't forget: a git gc alone can actually increase the size of the repo!)

To remove large files, the tool BFG can help too.

In short, don't mix-up:

  • a zip image (representing one revision of a repo)
  • the full repo (representing all commits)

The HEAD that you download as a zip is indeed smaller (you removed files).
But the full history still references them.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283