How to do it...

  1. 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 
  1. 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/' 
  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 
  1. If we look at the file now, we can see that the username and password are gone:
$ cat .credentials 
username = 
password = 
  1. 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. 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.216.174