Remove .gitignore'd files
Here is how to remove files and directories that are ignored by git (cf. .gitignore). May be useful following a test run, a build, etc.
$ git clean -dfX
Options:
-
-d
: Remove directories in addition to files. -
-f
: Force removal. Will refuse to remove anything if not provided. -
-X
: Remove only files that are present in .gitignore.
See git-clean(1).
Written by sprt
Related protips
1 Response
Note that this will remove the files from the file system, not from git tracked repository.
If you want to remove files from the git repository which are .gitignore
'd (technically: to unstage and remove paths only from the index) you can run this command:
git rm --cached `git ls-files -i --exclude-from=.gitignore`
And tun this command to see first which files will be removed from repository:
git ls-files -i --exclude-from=.gitignore
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#