Created
November 18, 2011 01:35
-
-
Save palexander/1375271 to your computer and use it in GitHub Desktop.
Remove a password from Git's 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
# Sync with the remote master | |
git pull | |
# Force your clone to look like HEAD | |
git reset --hard | |
# AGAIN, A WARNING: This can really break stuff! | |
# Run your filter branch command, replacing all instances of "password" with "your_password" | |
# The example looks for Ruby files ("*.rb"), you can change this to match your needs | |
git filter-branch --tree-filter 'git ls-files -z "*.rb" |xargs -0 perl -p -i -e "s#(password)#your_password#g"' -- --all | |
# Overwrite your master with local changes | |
git push origin master --force |
Still useful all these years later 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a godsend. Thank you so much for putting this up! :)