Last active
December 31, 2015 17:19
-
-
Save spikeheap/8019649 to your computer and use it in GitHub Desktop.
Script to purge large files from a git repository history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FILE_TO_DELETE="target" | |
| # Filter the history | |
| git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch ${FILE_TO_DELETE' --prune-empty --tag-name-filter cat -- --all | |
| # Purge the local repository and force garbage collection | |
| rm -rf .git/refs/original/ | |
| git reflog expire --expire=now --all | |
| git gc --prune=now | |
| git gc --aggressive --prune=now | |
| # Print new repository size | |
| git count-objects -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment