+9 votes
1 view
in Devops and Agile by (22.3k points)
edited by

How do you delete untracked local files from your current working tree?

1 Answer

+9 votes
by (38.3k points)
edited ago by

Removal of untracked files from the working tree

$git clean -n

$git clean -f

while working with -f be cautious that may delete files.

for removing directories, 

$ git clean -f -d 

   or

$git clean -fd.

For removing ignored files,

$git clean -f -X 

     or 

$git clean -fX

for removing ignored and non-ignored files, 

run git clean -f -x 

        or 

git clean -fx

here x is case sensitive in commands. 

If clean.requireForce is set to "true" (the default) in your configuration, you need to specify -f otherwise nothing will happen.

For more commands like this please go through the following tutorial that helps you to understand better

...