git - “git check-ignore *”和“git ls-files --other --ignored --exclude-standard”有什么区别?
问题描述
我正在尝试检查 git 忽略的文件,我发现 2 个命令显示相同的结果。
哪个是
git check-ignore *
git ls-files --others --ignored --exclude-standard
这似乎是不同的方法,但它会在任何情况下显示相同的结果吗?
解决方案
虽然没有具体记录,但不同之处在于git check-ignore <pathname>
它不会递归到子目录1,而git ls-files --others
会。
假设您的工作目录如下所示:
.
|-- ignored-file
|-- bin
| |-- another-ignored-file
在工作目录的根目录下,如果您运行:
git check-ignore *
你会得到公正ignored-file
的。如果你运行:
git ls-files --others --ignored --exclude-standard
你会得到:
ignored-filed
bin/another-ignored-file
现在,如果您要在bin
目录中运行这两个命令,您将获得相同的输出。
git check-ignore
接受通配符实际上有点令人惊讶,因为文档调用参数pathname而不是pathspec。更新:正如@LeGEC在评论中指出的那样,shell 正在解释路径名,因此支持通配符。
推荐阅读
- apache - mod_security 规则 981172 误报
- jquery - 按下上一个和下一个按钮时模拟元素列表中的元素单击
- vsto - Globals.ThisAddIn.Application.ActiveInspector == null 虽然显示了有效的 Outlook.AppointmentItem 为什么?
- openssl - 如何为 s_client 和 s_server 指定中间证书?
- c++ - SFML RenderWindow 需要时间打开
- c# - RabbitMq - ConversationId 与 CorrelationId - 哪个更适合跟踪特定请求?
- javascript - 获取自动生成的 ID - Firebase
- ios - PhotoKit:当用户删除 Photos.app 中的资产时如何删除源媒体文件?
- c# - 在 ASP.NET Core 应用程序中注入 EF 上下文并使用迁移
- c++ - 如何在没有先验知道其维度的情况下动态填充多维向量 c++