Created
February 21, 2018 18:32
-
-
Save WeZZard/64ec5fc1d4fde1ea310c312d9fda6791 to your computer and use it in GitHub Desktop.
Replaces sensitive texts in a git repository and fixes author and committer's info.
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/sh | |
export LC_CTYPE=C; | |
export LANG=C; | |
git filter-branch --tree-filter " | |
find . -type f -exec sed -i '' -E 's/sensitive-text/non-sensitive-text/g' {} + | |
" -f -- --all | |
git filter-branch --env-filter ' | |
OLD_EMAIL1="[email protected]" | |
OLD_EMAIL2="[email protected]" | |
CORRECT_NAME="correct_name" | |
CORRECT_EMAIL="[email protected]" | |
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL1" ] || [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL2" ] | |
then | |
export GIT_COMMITTER_NAME="$CORRECT_NAME" | |
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" | |
fi | |
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL1" ] || [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL2" ] | |
then | |
export GIT_AUTHOR_NAME="$CORRECT_NAME" | |
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" | |
fi | |
' --tag-name-filter cat -f -- --branches --tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment