Cleanup GIT content

Change commit contens

Sometimes you have committed some files with some content you don’t want to publish to a server.

You can use git-filter-repo not only to update Author and commit message, you can also update file contents.

in my case I had some files containing my email address. So I wanted to change this.

I used this little BASH script:

#!/usr/bin/env bash

# generate filter
cat <<EOF >/tmp/replace.txt
regex:(?i)@my-corporate\.com==>@example.com
EOF

# run the filter
git filter-repo --replace-text /tmp/replace.txt

# cleanup
rm /tmp/replace.txt

Please note the ==> and not == this water quite some time because I did not recognized this!

This is behause the whole history is rewritten. So you need to force the push!