Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easy way to delete untracked git files [duplicate]

Tags:

git

bash

git-bash

From time to time I have untracked files in my git repository and I'd like to delete them.

Is there an easy way to do so using git or bash or even another way?

like image 572
thitemple Avatar asked Jun 27 '17 13:06

thitemple


People also ask

Will reset hard remove untracked files?

git reset --hard is a classic command in this situation - but it will only discard changes in tracked files (i.e. files that already are under version control). To get rid of new / untracked files, you'll have to use git clean !

What is the command to remove the untracked files from the directory?

You can use the git clean command to remove untracked files. The -fd command removes untracked directories and the git clean -fx command removes ignored and non-ignored files. You can remove untracked files using a . gitignore file.


1 Answers

Use git clean command.

git clean -f -d # will delete all untracked directories and files.
like image 175
hspandher Avatar answered Sep 20 '22 17:09

hspandher