newren / git-filter-repo

Quickly rewrite git repository history (filter-branch replacement)
Other
8.52k stars 708 forks source link

Question: How to filter content of a specific file #509

Closed amitdo closed 3 days ago

amitdo commented 1 year ago

Hi,

Is there a way to use --replace-text or --blob-callback and restrict it to filter a specific filename (e.g.path/to/Makefile.am) ?

newren commented 3 days ago

The new --file-info-callback added in commit 615720731589 (filter-repo: add a --file-info-callback, 2024-10-23) permits doing this. That commit adds a callback which allows you to work with both the filename and file contents (and file mode), and includes the ability to apply the replacement text only to files of your choosing from within the callback.

amitdo commented 3 days ago

Thanks!