I finished an android project that requires me to use an api_key.
I've added the api key in my build.gradle file like this:
it.buildConfigField "String", "MDB_API_KEY", "\"243248324293938243\""
it.buildConfigField "String", "MDB_API_KEY", *putYaOwnApiKeyBrothar*
git filter-branch is the way to go. It has various filters and you can remove files from the history, but you can also modify the files as you like. In your case you want to use the
--tree-filter option with a command that replaces the String in your file. Something like
git filter-branch --tree-filter "sed -i 's/243248324293938243/putYaOwnApiKeyBrothar/' your/file/here" --tag-name-filter cat --all
(if you are on macOS (or any *BSD) add
'' after sed -i)