Created
February 7, 2012 19:35
-
-
Save berikv/1761420 to your computer and use it in GitHub Desktop.
Remove files from git history
This file contains 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
toRemove='someDirectory/* bigFile.txt' | |
# Remove every file that matches $toRemove | |
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch $toRemove" --prune-empty -- --all | |
# Rebuild the history cache (does not seem to remove big file from the git caches... maybe not required) | |
rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune | |
# Make a clean clone | |
cd .. | |
git clone --no-hardlinks ${REPO} ${REPO}-reduced | |
# Start using the new clone, remove the old repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment