Created
October 16, 2019 05:11
-
-
Save madhikarma/ca836d5ad78f1a6bb15be8e692a855f0 to your computer and use it in GitHub Desktop.
Git remove files/text from history snippet
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
# Remove folder (tested) | |
git filter-branch --tree-filter 'rm -rf FOLDER_PATH' --prune-empty HEAD | |
# Remove file (not tested) | |
git filter-branch --force --index-filter \ | |
"git rm --cached --ignore-unmatch FILE_PATH" \ | |
--prune-empty --tag-name-filter cat -- --all | |
# Remove text (not tested) | |
git filter-branch --tree-filter "find . -type f -exec sed -i -e 's/ORIGINAL_PASSWORD/NEW_PASSWORD/g' {} \;" | |
# Links | |
# https://blog.ostermiller.org/git-remove-from-history | |
# https://davidverhasselt.com/git-how-to-remove-your-password-from-a-repository/ | |
# https://help.github.com/en/articles/removing-sensitive-data-from-a-repository |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment