Skip to content

Instantly share code, notes, and snippets.

@andreyserdjuk
Created June 17, 2014 20:09
Show Gist options
  • Save andreyserdjuk/43742da9919fa6a8d5f0 to your computer and use it in GitHub Desktop.
Save andreyserdjuk/43742da9919fa6a8d5f0 to your computer and use it in GitHub Desktop.
git remove cached objects
#!/bin/sh -ev
git remote rm origin || true
git branch -D in || true
(
cd .git
rm -rf refs/remotes/ refs/original/ *_HEAD logs/
)
git for-each-ref --format="%(refname)" refs/original/ | xargs -n1 --no-run-if-empty git update-ref -d
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 -c gc.rerereunresolved=0 -c gc.pruneExpire=now gc "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment