GNU+Linux command memo

Save Git space

Réduire l’espace de stockage utilisé par Git.

Short on disk space ? Using Git?

$ git fetch --all --prune (1)
$ du -sh .git && git gc --aggressive && du -sh .git (2)
13M     .git
Enumerating […]
6.5M    .git
1 Drop all removed upstream branches. You may check if you want to keep them, they are still listed as dangling commits by git fsck before you git gc.
2 Compress the repository and see how much it worked ; can be up to 50%
It needs some available disk space and a lot of CPU & RAM to perform git gc --aggressive. It can take all the available RAM and swap for hours. A simple git gc might be considered for big repositories.

Thanks to @mmu_man at for the tip.

Something similar exists for svn :

$ du -s -h .svn && svn cleanup && du -s -h .svn
1.5G    .svn/
785M    .svn/

On a virtualbox svn checkout, it saved 700 MO.