我如何进行‘git status‘,以便在不使用.gitignore的情况下不显示未跟踪的文件?

本文介绍了如何在不显示未跟踪文件的情况下执行`git status`,强调了从git 1.8.3版本开始,用户可以通过使用`--short`选项快速获取已跟踪文件的状态,而不需要`gitignore`。文中还提供了不同命令的等效用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文翻译自: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 specifying normal ), 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 use no to have git status return more quickly without showing untracked files . 您可以使用no来更快地返回git status而不显示未跟踪的文件

The default can be changed using the status.showUntrackedFiles configuration variable documented in git 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值