How to remove local untracked files from current Git branch

By | August 8, 2020
If you want to remove files and directories that are not being tracked then you could easily remove them by following this small trick. You can remove all untracked files by using GIT git-clean command.

Remove untracked files from current git branch

 git clean -f 
Run above code to delete all unwanted files from your current working tree. However, if you wish to view the files and directories that will be deleted with above command then run below code.

 git clean -n 

This is a good practice to view files before deleting them. First make sure the files that are going to be deleted is needed or not then run first command.

Below are some options available in GIT for you to delete files, directories and ignored files.


  • If you want to remove directories then run git clean -f -d or git clean -fd
  • If you want to remove only ignored files then run git clean -f -X or git clean -fX
  • If you want remove ignored and non-ignored files then run git clean -f -x or git clean -fx
Read more about how to rename git branch 
Category: GIT

Leave a Reply

Your email address will not be published. Required fields are marked *