DEV Community

Discussion on: Shrinking your git repository with BFG Repo-Cleaner

Collapse
 
tbroyer profile image
Thomas Broyer

Fwiw, do you know about git filter-repo? It's the officially recommended replacement for git filter-branch, and does what you needed to do and much more.

Your commands map to it as:
Approach 1

git filter-repo --strip-blobs-bigger-than 20M
Enter fullscreen mode Exit fullscreen mode

Approach 2

// Delete a single file
git filter-repo --invert-paths --use-base-name --path 'some-image-that-was-not-needed.png'

// Delete many matching files
git filter-repo --invert-paths --use-base-name --path-glob '*.apk' --path-glob '*.app' --path yarn.lock

// Delete a folder
git filter-repo --invert-paths --use-base-name --path build
Enter fullscreen mode Exit fullscreen mode

(--invert-paths is needed here as by default filter-repo will keep what matches, so you need to tell it to keep everything but what you want to remove)