在git管理的項(xiàng)目下, 做一些編譯或者運(yùn)行測試的操作,會產(chǎn)生一些未追蹤的文件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, 強(qiáng)制刪除 untracked
文件 - -d:刪除整個文件夾,-fd 強(qiáng)制刪除 untracked 文件和文件夾
- -n: 查看會刪掉哪些文件,防止重要文件被誤刪