Created
September 23, 2012 20:37
-
-
Save kgaughan/3772976 to your computer and use it in GitHub Desktop.
Aggressively compact a git repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git fsck --unreachable | |
git reflog expire --expire=0 --all | |
git repack -a -d -l | |
git prune | |
git gc --aggressive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find all git remotes:
git remote -v
Remove git remotes:
git remote remove origin
(where origin is a list of all remotes)To check if your commits are GPG/PGP signed:
git log --pretty="%G?" | uniq
Get a list of all unreferenced objects
git fsck --unreachable --dangling --no-reflogs --root --tags --cache --full --strict --lost-found
Expire all unreferenced objects:
git reflog expire --updateref --rewrite --stale-fix --expire=all --all
Repack only referenced objects:
time git repack -A -d -f -F --unpack-unreachable=all --window=4095 --depth=4095
(4095 may be way too slow for bigger projects, it's the maximum)Remove unreferenced objects:
git prune --expire=all
Garbage collect packfile:
git gc --prune=now --aggressive