I want to clean up files which ignored by .gitignore, but I want to exclude some files specified by excluding options. And then, I don't want to remove untracked files.
dist (ignored)
node_modules (ignored)
.env (ignored but I want to exclude for the cleanup)
I_do_not_want_add_yet.js (untracked, I don't want cleanup some untracked files)
package.json (There are many other tracked files)
So I looked into some posts and tried the following command:
$ git clean -ndX -e .env
Would remove dist/
Would remove node_modules/
Would remove .env # Oops!
$ git clean -ndX --exclude='!.env'
Would remove dist/
Would remove node_modules/
Would remove .env # Oops!
$ git clean -ndx -e .env
Would remove dist/
Would remove node_modules/
Would remove I_do_not_want_add_yet.js # Oops!
Do you have good ideas?