在git管理的项目下, 做一些编译或者运行测试的操作,会产生一些未追踪的文件Untracked files
, 可以使用git clean命令来删除。
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: info.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
test/log/
test/info.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git clean -nfd
Would remove test/log/
Would remove test/info.txt
$ git clean -fd
Removing test/log/
Removing test/info.txt
- -f: --force, 强制删除 untracked
文件
- -d:删除整个文件夹,-fd 强制删除 untracked 文件和文件夹
- -n: 查看会删掉哪些文件,防止重要文件被误删