Skip to content

Instantly share code, notes, and snippets.

@djaney
Last active April 22, 2020 03:01
Show Gist options
  • Save djaney/91c27861b53b8558c31b9897ca405bf5 to your computer and use it in GitHub Desktop.
Save djaney/91c27861b53b8558c31b9897ca405bf5 to your computer and use it in GitHub Desktop.
Cleanup bloated git

get list of bloated files

git rev-list master | while read rev; do git ls-tree -lr $rev | cut -c54- | sed -r 's/^ +//g;'; done | sort -u | sort -rnk1 | head -n 20

Remove selected file from the historybooks!

replace DUMBFILE

git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch DUMBFILE' --prune-empty -f -- --all

Garbage collection

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --aggressive --prune=now

Force push!

git push origin --force --all
git push origin --force --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment