Last active
December 14, 2015 15:28
-
-
Save kavu/5107579 to your computer and use it in GitHub Desktop.
This is how you can delete some HUGE dir in your repo's history. Warning! Make a backup and don't try it, if you don't understand what are you doing!
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
# Let's figure out what we have in the beggning | |
git fsck --full --strict --unreachable | |
git count-objects -v | |
# Filter ALL branches deleteing `db/seeds_assets` | |
git filter-branch -f --tree-filter 'rm -rf db/seeds_assets' -- --all | |
# Remove original reflogs | |
rm -rf .git/refs/original/ | |
# Expire old and unuses reflogs | |
git reflog expire --expire=now --expire-unreachable=now --all --rewrite | |
# Compress | |
git gc --aggressive --prune=now | |
# Let's check again | |
git fsck --full --strict --unreachable | |
git count-objects -v | |
# Push all branches to the origin | |
git push origin --all --force -u | |
## Additional links | |
# http://git-scm.com/book/en/Git-Internals-Maintenance-and-Data-Recovery | |
# http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository | |
# https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html#_checklist_for_shrinking_a_repository | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment