How to remove local (untracked) files from the current Git working tree

前端 未结 30 2143
死守一世寂寞
死守一世寂寞 2020-11-22 00:07

How do you delete untracked local files from your current working tree?

30条回答
  •  粉色の甜心
    2020-11-22 01:04

    I am surprised nobody mentioned this before:

    git clean -i
    

    That stands for interactive and you will get a quick overview of what is going to be deleted offering you the possibility to include/exclude the affected files. Overall, still faster than running the mandatory --dry-run before the real cleaning.

    You will have to toss in a -d if you also want to take care of empty folders. At the end, it makes for a nice alias:

    git iclean
    

    That being said, the extra hand holding of interactive commands can be tiring for experienced users. These days I just use the already mentioned git clean -fd

提交回复
热议问题