Skip to content

Instantly share code, notes, and snippets.

@mLuby
Created August 7, 2018 06:21
Show Gist options
  • Save mLuby/6e5f3192e423ffb45947ed3b6dc8b514 to your computer and use it in GitHub Desktop.
Save mLuby/6e5f3192e423ffb45947ed3b6dc8b514 to your computer and use it in GitHub Desktop.
replace word in git history
git co master && git branch -D master-backup ; git co -b master-backup && git co master
ls -ra db/ | grep -E '\.![0-9]+\!' # should return no results
cat known/location/of/secret | grep secret # should return results
LC_CTYPE=C && LANG=C && git filter-branch --tree-filter "find . -type f -exec sed -i '' -e 's/secret/replacement/g' {} \;" -f
ls -ra db/ | grep -E '\.![0-9]+\!' # should return no results
cat known/location/of/secret | grep secret # should return no results
git filter-branch --tree-filter "grep -r 'secret' * || true"
git push -f origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment