I know how to use filter-branch to completely leave a file out of the repository history. What happened is that I had slightly sensitive information in a file some commits ago, but I have removed it and I want to keep the file from that safe commit onwards.
Can I do it? Or will I have to to do some cloning tricks?
I think BFG Repo-Cleaner is exactly what you're looking for.
You can use it to replace or remove sensitive information contained in the working tree (like for example a password) throughout the history of the repository. Here's an example from their documentation :
bfg --replace-text passwords.txt /path/to/repository
The passwords.txt
file would then contain a series of strings to match together with what value they should be replaced with. For example:
password # Replaces the string 'password' with '***REMOVED***' (default)
password==>DELETED # Replaces the string 'password' with 'DELETED'
password==> # Replaces the string 'password' with an empty string
regex:password.+==> # Replaces using a regular expression with an empty string
As with git-filter-branch
, this is a rewrite history operation, so the usual disclaimer applies.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.