Git clean -f -d

How to use git clean -f -d

Panjeh
1 min readJan 30, 2021

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

Just run this:

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.

If you want to remove 1) untracked directories with 2) all their contents, in addition to what is done by git clean -f , you need to run:

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.

With a staged file, the above commands git clean -f or git clean -f -d will not work.

I would like to introduce two packages for Laravel that I have recently developed: Laravel Pay Pocket, a modern multi-wallet package, and Laravel Failed Jobs, a UI for the Laravel Failed Jobs Table. I hope they may be of help to you.

https://github.com/HPWebdeveloper/laravel-pay-pocket
https://github.com/HPWebdeveloper/laravel-failed-jobs

--

--