I want to eliminate sensitive data that appears in the diff when commits are compared on github, for x reasons I put a sensitive data in a field, and after changing it and pushing it, this data continues to appear in the commit history as part of a change in a commit, how can I solve this problem, without deleting the commit?
As it is a piece of text within a file and not a whole file, it is somewhat more complicated, but you can copy the content of the file and use:
git filter-branch
o BFG Repo-CleanerHead over here for more information.
Extensive information:
You have to use BFG Repo-Cleaner as it is faster and has more options than
git filter-branch
:First you have to create a file and inside put the text you want to replace:
Then using BFG you have to run this:
What will happen is that it will look for "I am sensitive data" and change it to * * * REMOVED * * *
I insist: Read carefully the link to expand the information since it is a sensitive thing.