Git clean -f -d
How to use git clean -f -d
Be careful with the following commands, they delete files permanently!
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
- In the following commands,
- 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
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.