Git clean -f -d

How to use git clean -f -d

Important note:

Be careful with the following commands, they delete files permanently!

Explanation:

If you want to just remove all untracked files inside:

  • The main root directory
  • Or other already tracked (committed) directories
git clean -f

Note 1:

  • In the following commands, -f means force.
  • Also the new (untracked) files that are inside the new (untracked) directories will not be removed by the above command.
git clean -f -d

Note 2:

If you stage a new file, it is no longer an untracked file. Remember we can stage a file with git add file_name.