So I just had the issue, that I encountered a long running local tracking git repo to be huge.
And it wasn’t that there are huge (lfs) files stored in it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| # du -h --max-depth=1 --exclude=.git /var/www/pma.heimdaheim.de/www/
60K /var/www/pma.heimdaheim.de/www/.github
676K /var/www/pma.heimdaheim.de/www/doc
20K /var/www/pma.heimdaheim.de/www/examples
9.0M /var/www/pma.heimdaheim.de/www/js
5.8M /var/www/pma.heimdaheim.de/www/libraries
59M /var/www/pma.heimdaheim.de/www/po
92K /var/www/pma.heimdaheim.de/www/scripts
28K /var/www/pma.heimdaheim.de/www/setup
28K /var/www/pma.heimdaheim.de/www/sql
1.5M /var/www/pma.heimdaheim.de/www/templates
3.3M /var/www/pma.heimdaheim.de/www/test
9.0M /var/www/pma.heimdaheim.de/www/themes
20M /var/www/pma.heimdaheim.de/www/vendor
92M /var/www/pma.heimdaheim.de/www/node_modules
28K /var/www/pma.heimdaheim.de/www/tmp
200M /var/www/pma.heimdaheim.de/www/
|
Now after looking at that, we can take a closer look into the git-directory itself (as to what is consuming the space):
1
2
3
4
5
6
7
8
| # du -h --max-depth=1 /var/www/pma.heimdaheim.de/www/.git
52K /var/www/pma.heimdaheim.de/www/.git/hooks
0 /var/www/pma.heimdaheim.de/www/.git/branches
68K /var/www/pma.heimdaheim.de/www/.git/info
32K /var/www/pma.heimdaheim.de/www/.git/refs
1.5G /var/www/pma.heimdaheim.de/www/.git/objects
68K /var/www/pma.heimdaheim.de/www/.git/logs
1.2G /var/www/pma.heimdaheim.de/www/.git
|
As you can see, the git objects directory is a wopping 1.5GB. There is two ways to clean that:
a) git fetch –prune
b) git repack -a -d –depth=250 –window=250
After doing b) lets look at the git directory again:
1
2
3
4
5
6
7
8
| # du -h --max-depth=1 /var/www/pma.heimdaheim.de/www/.git
52K /var/www/pma.heimdaheim.de/www/.git/hooks
0 /var/www/pma.heimdaheim.de/www/.git/branches
68K /var/www/pma.heimdaheim.de/www/.git/info
32K /var/www/pma.heimdaheim.de/www/.git/refs
1.2G /var/www/pma.heimdaheim.de/www/.git/objects
68K /var/www/pma.heimdaheim.de/www/.git/logs
1.2G /var/www/pma.heimdaheim.de/www/.git
|