Skip to content

Instantly share code, notes, and snippets.

@amenk
Last active August 29, 2015 14:02
Show Gist options
  • Save amenk/aa98d11015c73090923d to your computer and use it in GitHub Desktop.
Save amenk/aa98d11015c73090923d to your computer and use it in GitHub Desktop.
Clean media folder from repository
git clone repo-backup/ repo-min
cd repo-min/
# make sure you do not have other branches
git filter-branch --tree-filter 'rm -rf public/media/*' HEAD
git update-ref -d refs/original/refs/heads/master
git remote rm origin
git repack -ad
du -hs .git # 2.4 GB
git whatchanged # check that files are not there
git reflog expire --expire=now --all
git gc --prune=now --aggressive
du -hs .git # 70 MB
git add origin .....
git push --mirror origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment