In addition to the popular answer above I would like to add a few notes for Windows-systems. The command
git filter-branch --tree-filter 'rm -rf node_modules' --prune-empty HEAD
works perfectly without any modification! Therefore, you must not use Remove-Item
, del
or anything else instead of rm -rf
.
If you need to specify a path to a file or directory use slashes like ./path/to/node_modules