目录 搜索
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
文字

命名

git-clean  - 从工作树中删除未跟踪的文件

概要

git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>…

描述

通过从当前目录开始递归地移除不受版本控制的文件来清除工作树。

通常,只有Git未知的文件才会被删除,但是如果-x指定了该选项,则也会删除被忽略的文件。例如,这可以用于删除所有构建产品。

如果<path>...给出任何可选参数,则只有那些路径受到影响。

选项

-d

除了未跟踪的文件之外,还要除去未跟踪的目录。如果未跟踪的目录由不同的Git存储库管理,则默认情况下不会删除它。如果您真的想删除这样的目录,请使用-f选项两次。

-f   --force

如果Git配置变量clean.requireForce未设置为false,git clean将拒绝删除文件或目录,除非给定-f,-n或-i。除非给出第二个-f,否则Git将拒绝使用.git子目录或文件删除目录。

-i   --interactive

以交互方式显示将要完成的操作和清理文件。有关详情,请参阅“交互模式”。

-n   --dry-run

不要实际删除任何东西,只显示会做什么。

-q   --quiet

Be quiet,只报告错误,而不是成功删除的文件。

-e <pattern>   --exclude=<pattern>

除了在.gitignore(每个目录)和$ GIT_DIR / info / exclude中发现的内容外,还应将这些模式视为有效的忽略规则集。

-x

不要使用从.gitignore(每个目录)和$ GIT_DIR / info / exclude读取的标准忽略规则,但仍然使用与-e选项一起提供的忽略规则。这允许删除所有未跟踪的文件,包括构建产品。这可以用来(可能与其结合git reset)创建一个原始工作目录来测试一个干净的构建。

-X

只删除Git忽略的文件。这对从头开始重建所有内容可能很有用,但保留手动创建的文件。

Interactive mode

当命令进入交互模式时,它显示要清理的文件和目录,并进入其交互式命令循环。

命令循环显示可用的子命令列表,并提示“What now>”。通常,当提示以单个结尾时>,您可以只选择其中一个选项并输入return,如下所示:

    *** Commands ***        1: clean                2: filter by pattern    3: select by numbers        4: ask each             5: quit                 6: help
    What now> 1

只要选择是独一无二的,你也可以说cclean以上。

主要的命令循环有6个子命令。

clean

开始清理文件和目录,然后退出。

按模式过滤

这显示了要删除的文件和目录,并发出“输入忽略模式>>”提示。您可以输入空格分隔的模式以从删除中排除文件和目录。例如“* .c * .h”将删除以“.c”和“.h”结尾的文件。当您对筛选结果满意时,按ENTER(空)回到主菜单。

按数字选择

这显示要删除的文件和目录并发出“选择要删除的项目>>”提示。当提示以双精度结束时>>,可以进行多个选择,并将其与空格或逗号连接。你也可以说范围。例如“2-5 7,9”从列表中选择2,3,4,5,7,9。如果省略范围中的第二个数字,则选择所有剩余的项目。例如“7-”从列表中选择7,8,9。你可以说*选择一切。另外,当您对筛选结果满意时,请按ENTER(空白)回到主菜单。

询问每一个

这将开始清理,并且您必须逐个确认以删除项目。请注意,此操作不如上述两项操作有效。

quit

这可以让你不做清洁就退出。

help

显示交互式git-clean的简要用法。

上一篇: 下一篇: