In this short article, we want to show how to remove unnecessary files and compress required files in a better way in the
Quick solution (run the following command in your project directory):
git gc --prune=now
Enumerating objects: 1210, done. Counting objects: 100% (1210/1210), done. Delta compression using up to 24 threads Compressing objects: 100% (1054/1054), done. Writing objects: 100% (1210/1210), done. Total 1210 (delta 253), reused 0 (delta 0), pack-reused 0
Note: the above operation reduced
.gitdirectory size for the presented output from 2.61GB to 0.98GB.
From Git Documentation:
Prune loose objects older than date (default is 2 weeks ago, overridable by the config variable
--prune=nowprunes loose objects regardless of their age and increases the risk of corruption if another process is writing to the repository concurrently; see "NOTES" below.
--pruneis on by default.