Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh
# The job of git-flush is to recompactify your repository to be as small
# as possible, by dropping all reflogs, stashes, and other cruft that may
# be bloating your pack files.
git for-each-ref --format="%(refname)" refs/original/ | \
xargs -n 1 git update-ref -d
git reflog expire --expire=0 --all
if [ "$1" = "-f" ]; then
git stash clear
fi
git gc --prune=now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment