gpt4 book ai didi

git - "git check-ignore *"和 "git ls-files --other --ignored --exclude-standard"有什么区别?

转载 作者:行者123 更新时间:2023-12-04 12:21:34 27 4
gpt4 key购买 nike

我正在尝试检查被 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 实际上有点令人惊讶完全接受通配符,因为文档调用参数路径名而不是 pathspec . 更新:@LeGECcomments 中指出,shell 正在解释路径名,因此支持通配符。
  • 关于git - "git check-ignore *"和 "git ls-files --other --ignored --exclude-standard"有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69084527/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com