Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BFG Repo-Cleaner --replace-text example
PASSWORD1 # Replace literal string 'PASSWORD1' with '***REMOVED***' (default)
PASSWORD2==>examplePass # replace with 'examplePass' instead
PASSWORD3==> # replace with the empty string
regex:password=\w+==>password= # Replace, using a regex
regex:\r(\n)==>$1 # Replace Windows newlines with Unix newlines
@mevers303

This comment has been minimized.

Copy link

@mevers303 mevers303 commented May 10, 2018

Thanks!

@BarbzYHOOL

This comment has been minimized.

Copy link

@BarbzYHOOL BarbzYHOOL commented Sep 29, 2018

Very useful.

regex:(?i)(barbz)==> # Matches "barbz" insensitively

@fcu423

This comment has been minimized.

Copy link

@fcu423 fcu423 commented Dec 18, 2018

Hi!

Do you know if there's anyway to use the BFG command to delete files but applying it only to an specific path in the repository?

Several files might match the regex expressions that I'm building but I would like to filter so that it only applies to the files I want.

Thanks!

@williamclot

This comment has been minimized.

Copy link

@williamclot williamclot commented Dec 8, 2020

I found these two flags @fcu423, maybe they can help:
--filter-content-including <glob> do file-content filtering on files that match the specified expression (eg '*.{txt,properties}') --filter-content-excluding <glob> don't do file-content filtering on files that match the specified expression (eg '*.{xml,pdf}')

@farazdurrani

This comment has been minimized.

Copy link

@farazdurrani farazdurrani commented May 14, 2021

For those who want to know which flavor of regex is accepted by regex, it's the one that's used with grep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment