Skip to content

Instantly share code, notes, and snippets.

@kgaughan
Created September 23, 2012 20:37
Show Gist options
  • Save kgaughan/3772976 to your computer and use it in GitHub Desktop.
Save kgaughan/3772976 to your computer and use it in GitHub Desktop.
Aggressively compact a git repository
git fsck --unreachable
git reflog expire --expire=0 --all
git repack -a -d -l
git prune
git gc --aggressive
@MarcusJohnson91
Copy link

MarcusJohnson91 commented Mar 27, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment