Created
November 14, 2019 14:55
-
-
Save j18e/91cf4e1fae22e1e6e6600974289a1ef3 to your computer and use it in GitHub Desktop.
Remove file(s) from git 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
#!/bin/bash -eu | |
git filter-branch --force --index-filter \ | |
'git rm --cached --ignore-unmatch src/images/my_large_photos_*.jpg' \ | |
--prune-empty --tag-name-filter cat -- --all | |
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin | |
git reflog expire --expire=now --all | |
git gc --prune=now --aggressive | |
# when all this is done, verify that everything looks good and run git push -f | |
# be sure to back up your repo beforehand! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment