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

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

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

30条回答
  •  野的像风
    2020-11-22 01:01

    Use git clean -f -d to make sure that directories are also removed.

    1. Don’t actually remove anything, just show what would be done.

      git clean -n
      

      or

      git clean --dry-run
      
    2. Remove untracked directories in addition to untracked files. If an untracked directory is managed by a different Git repository, it is not removed by default. Use the -f option twice if you really want to remove such a directory.

      git clean -fd
      

    You can then check if your files are really gone with git status.

提交回复
热议问题