本文翻译自:How do I do a 'git status' so it doesn't display untracked files without using .gitignore?
How do I do a git status
so it doesn't display untracked files without using .gitignore
? 如何做一个git status
,因此不会不使用显示未跟踪文件.gitignore
? I want to get modification status information on tracked files only. 我想仅获取有关跟踪文件的修改状态信息。
#1楼
参考:https://stackoom.com/question/2Uir/我如何进行-git-status-以便在不使用-gitignore的情况下不显示未跟踪的文件
#2楼
Note that, since git 1.8.3 (April, 22d 2013) , you will know about the --untracked-files=no
even if you didn't add that option in the first place! 请注意,从git 1.8.3(2013年4月22日)开始 ,即使你没有首先添加该选项,你也会知道--untracked-files=no
!
"
git status
" suggests users to look into using--untracked-files=no
option when it takes too long. “git status
”建议用户在花费太长时间时使用--untracked-files=no
选项。
See commit https://github.com/git/git/commit/5823eb2b28696bf0eb25f6ca35b303447869f85 : 请参阅提交https://github.com/git/git/commit/5823eb2b28696bf0eb25f6ca35b303447869f85 :
In some repositories users experience that "
git status
" command takes long time. 在某些存储库中,用户会体验到“git status
”命令需要很长时间。
The command spends some time searching the file system for untracked files. 该命令花费一些时间在文件系统中搜索未跟踪的文件。Explain the trade-off struck by the default choice of
normal
to help users make an appropriate choice better, before talking about the configuration variable. 在讨论配置变量之前,解释默认选择normal
以达到的权衡,以帮助用户更好地做出适当的选择。
The git status
documentation now states: git status
文档现在声明:
When
-u
option is not used, untracked files and directories are shown (ie the same as specifyingnormal
), to help you avoid forgetting to add newly created files. 如果未使用-u
选项,则会显示未跟踪的文件和目录(即与指定normal
文件相同),以帮助您避免忘记添加新创建的文件。
Because it takes extra work to find untracked files in the filesystem, this mode may take some time in a large working tree. 由于在文件系统中查找未跟踪文件需要额外的工作,因此在大型工作树中此模式可能需要一些时间。
You can useno
to havegit status
return more quickly without showing untracked files . 您可以使用no
来更快地返回git status
而不显示未跟踪的文件 。The default can be changed using the
status.showUntrackedFiles
configuration variable documented ingit config
. 可以使用git config
记录的status.showUntrackedFiles
配置变量来更改默认值。
#3楼
Use this: 用这个:
git status -uno
which is equivalent to: 这相当于:
git status --untracked-files=no
It's a bit hidden in the manuals, but the manpage for status says "supports the same options as git-commit", so that's where you'd have to look. 它在手册中有点隐藏,但状态的联机帮助页显示“支持与git-commit相同的选项”,因此这是您必须查看的位置。
#4楼
也:
git config status.showuntrackedfiles no