Last Updated: October 07, 2020
·
1.004K
· nigro

clean untracked files

rm $(git ls-files --other --exclude-standard)

You can setup git alias for this in your .git/config file:

[alias]

clean-untracked = !sh -c 'rm $(git ls-files --other --exclude-standard)' -

then you can use it as a normal git command:

git clean-untracked

1 Response
Add your response

Why not git clean -df?
To show what will be removed you can use git clean -ndf.
Also clean-untracked may leave empty directories but git clean removes untracked directories entirely.

over 1 year ago ·