如何在不使用 .gitignore 的情况下执行“git status”以便不显示未跟踪的文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/594757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 06:12:43  来源:igfitidea点击:

How do I do a 'git status' so it doesn't display untracked files without using .gitignore?

gitversion-control

提问by Ross Rogers

How do I do a git statusso it doesn't display untracked files without using .gitignore? I want to get modification status information on tracked files only.

我该怎么做才能在git status不使用的情况下不显示未跟踪的文件.gitignore?我只想获取有关跟踪文件的修改状态信息。

回答by Daniel Bruce

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 相同的选项”,所以这就是您必须查看的地方。

回答by Bombe

Also:

还:

git config status.showuntrackedfiles no

回答by VonC

Note that, since git 1.8.3 (April, 22d 2013), you will know about the --untracked-files=noeven if you didn't add that option in the first place!

请注意,从git 1.8.3 (April, 22d 2013) 开始--untracked-files=no即使您没有首先添加该选项,您也会知道!

"git status" suggests users to look into using --untracked-files=nooption 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.
The command spends some time searching the file system for untracked files.

Explain the trade-off struck by the default choice of normalto help users make an appropriate choice better, before talking about the configuration variable.

在某些存储库中,用户会遇到“ git status”命令需要很长时间。
该命令会花费一些时间在文件系统中搜索未跟踪的文件。

normal在讨论配置变量之前,解释一下默认选择的权衡,以帮助用户更好地做出适当的选择。

The git statusdocumentationnow states:

git status文档现在状态:

When -uoption is not used, untracked files and directories are shown (i.e. the same as specifying normal), to help you avoid forgetting to add newly created files.
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 use noto have git statusreturn more quickly without showing untracked files
.

The default can be changed using the status.showUntrackedFilesconfiguration variable documented in git config.

-u不使用选项,未跟踪文件和目录显示(即等同于指定normal),以帮助用户避免忘记添加新创建的文件。
因为在文件系统中查找未跟踪的文件需要额外的工作,所以这种模式在大型工作树中可能需要一些时间。
您可以使用nogit status回报更快,而不显示未跟踪文件

可以使用 中记录的status.showUntrackedFiles配置变量更改默认值git config