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