One of the things I really like about git is that it doesn't automatically garbage collect and compact repositories. It's kind of like how you don't clean your room and take out the garbage (or at least I don't) every time you make a mess or throw something away. If you accidently throw something away, you can pull it out of the trash before it goes to the dump. You don't have to be slowed down by a clean up operation when you're focusing on getting things done.
However, there is a draw back to this. Git repositories DO start to slow down after a while if you aren't "cleaning your room". And, they won't be as efficient in disk space utilization.
Lucky for us, since we are working with computers here, we don't have to clean our rooms by hand. The following little bash script will crawl your whole hard drive, look for any git repositories, and then garbage collect, prune, and pack them, regaining your disk space and making your repositories operate faster:
#!/bin/sh find . -type d -name .git | while read dir; do pushd "$dir"; git gc --prune; popd; done
PS: ref logs keep objects from being pruned. More on ref logs in a future post.