I\'m trying to rewrite history, using:
git filter-branch --tree-filter \'git ls-files -z \"*.php\" |xargs -0 perl -p -i -e \"s#(PASSWORD1|PASSWORD2|PASSWORD3)#
Build it from the inside out. Say the password is
a$b'c\d
The regex pattern would be
a\$b'c\\d
One possibility for the perl command would be
perl -i -pe's/a\$b'\''c\\d/.../g'
(Note how each ' was replaced with '\''.)
Now you need to include that in single quotes, so you repeat the process.
... '... perl -i -pe'\''s/a\$b'\''\'\'''\''c\\d/.../g'\''' ...