Skip to content

Instantly share code, notes, and snippets.

@thomheymann
Created February 25, 2017 13:34
Show Gist options
  • Save thomheymann/41ac54636060b84a743bb7972c5c7598 to your computer and use it in GitHub Desktop.
Save thomheymann/41ac54636060b84a743bb7972c5c7598 to your computer and use it in GitHub Desktop.
# `git clean` seems to ignore -e option when used with -X so had to replicated its behaviour using `git ls-files`
# only remove ignored files / folders
git clean -Xd # this works fine
git ls-files --directory --others --exclude-standard --ignored | xargs rm -rf # same as above
# only remove ignored files / folders but keep node_modules folder
git clean -Xd -e node_modules # exclude option is ignored
git ls-files --directory --others --exclude-standard --ignored | grep node_modules --invert-match | xargs rm -rf # this works fine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment