DESCRIPTION Cleans the working tree by recursively removing files that are not under version control, starting from the current directory. 通过递归地删除没有在版本控制系统下的文件来清理工作树,从命令行当前目录开始递归
Normally, only files unknown to Git are removed, but if the -x option is specified, ignored files are also removed. This can, for example, be useful to remove all build products. 通常,只有git系统没有感知到文件才会被删除,但如果添加了-x 参数的话,被ignore(一般是在.gitignore中指定)的文件也会被删除,例如,-x这个参数被用来删除所有构建出来的内容
If any optional <pathspec>... arguments are given, only those paths that match the pathspec are affect. 如果 pathspec 路径参数指定了的话,只有该指定路径下的文件会执行clean命令
-f, --force If the Git configuration variable clean.requireForce is not set to false, git clean will refuse to delete files or directories unless given -f or -i. Git will refuse to modify untracked nested git repositories (directories with a .git subdirectory) unless a second -f is given.
-i, --interactive Show what would be done and clean files interactively. See “Interactive mode” for details.
-n, --dry-run Don’t actually remove anything, just show what would be done.
-q, --quiet Be quiet, only report errors, but not the files that are successfully removed.
-e <pattern>, --exclude=<pattern> Use the given exclude pattern in addition to the standard ignore rules (see gitignore(5)).
-x Don’t use the standard ignore rules (see gitignore(5)), but still use the ignore rules given with -e options from the command line. This allows removing all untracked files, including build products. This can be used (possibly in conjunction with git restore or git reset) to create a pristine working directory to test a clean build.
-X Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files.