As we need to modify a file when rewriting the history of this repository, we'll use the tree-filter option to filter the branch. The .credentials file looks as follows:
username = foobarpassword = verysecret
All we need to do is remove everything after the equals sign on each line of the file. We can use the following sed command to do this:
sed -i '' -e 's/^(.*=).*$/1/'
We can now run the filter branch with the following command:
If we look at the file now, we can see that the username and password are gone:
$ cat .credentialsusername =password =
As we saw in the previous example, we still need to clean up after filter-branch, by deleting original references, expiring the reflog, and triggering garbage collection. But, at this point, you can compare the content and commit history of the repository.