- 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 = foobar password = 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:
$ git filter-branch --prune-empty --tree-filter "test -f .credentials && sed -i '' -e 's/^\(.*=\).*$/\1/' .credentials || true" -- --all
- If we look at the file now, we can see that the username and password are gone:
$ cat .credentials username = password =
- As we saw in the previous ...