A Git user needs to perform regular local repo maintenance for repo performance and its health. Thankfully, this is very simple – yet I’m surprised at how many users are unaware of this command and the need for it.
The main command for maintenance is gc. gc optimizes and removes no-longer used data from the local repo. It is Git’s “garbage collector” and optimizer.
Typically, I occasionally run:
git gc --aggressive
The –aggressive option causes it to run longer, but does a much more thorough job. Depending on your local repo size and computer performance, it might not take more than another 30 seconds to run.
There are additional configuration options for gc as well. Please consult the git gc help for further info.