h8qvbw
Last Updated: February 25, 2016
·
1.389K
· mlen

Removing files from git

git

Removing untracked files can be hard, so there is one-liner for that:

git ls-files --exclude-standard --other | xargs rm -f 

Above line removes only untracked files. For removing ignored files run that:

git ls-files --ignored --exclude-standard --other | xargs rm -f

To remove both untracked and ignored files run this:

git ls-files --other | xargs rm -f 

1 Response
Add your response

2916

"git clean" would be another option. With -x, it will also remove both untracked and ignored files.

I have a git alias "distclean" that maps to "clean -ffdx". Very handy.

over 1 year ago ·