Archived post: posted sometime between 2016 and 2022.

git clean with multiple exclude patterns

Separate the exclude patterns with -e .

git clean -xfd -e *.js -e *.map -n

That will delete everything except *.js and *.map files. The -n does a dry-run to be safe.

See git clean -h for more details.