Created
August 9, 2021 04:03
-
-
Save martinratinaud/b01c615c131693a9097755a85a0cbf3e to your computer and use it in GitHub Desktop.
Remove a password (or unwanted string) commited in github (or gitlab) 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 | |
git filter-branch --tree-filter "find . -name 'ops/roles/ota/files/.env' -exec sed -i -e \ | |
's/<thepasswordtoremove>/***REMOVED***/g' {} \;" | |
git reflog expire --expire=now --all && git gc --prune=now --aggressive | |
git push --force --all | |
# If this commit was hosted on github, you will still be able to access the failing commit on the web | |
# which is not what you want | |
# This is because GitHub needs to run garbage collection and this will be done manually upon request | |
# This way dangling commit will be removed | |
open https://support.github.com/contact?tags=rr-general-technical | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment