【问题标题】:How to select multiple file types with glob matching in git如何在 git 中选择具有 glob 匹配的多种文件类型
【发布时间】:2014-03-14 00:21:11
【问题描述】:

我有以下:

$ tree
.
├── bar
│   ├── foo.js
│   ├── foo.herp
│   ├── foo.derp
│   └── foo.py
├── bar.herp
└── baz.py

我想用下面的

git ls-files -- {} 其中{} 是某种全局模式

我希望它返回

bar/foo.js
bar/foo.py
baz.py

【问题讨论】:

  • * 有什么问题?
  • @Anthony 你想做什么? git ls-files 已经以您提供的示例格式返回文件路径。
  • 啊,我会更新问题。这是深夜,我忘记表明我只想要 js 和 py 而不是其他任何东西

标签: git glob


【解决方案1】:

你可以在 ls-files 之后提供任意数量的 glob 表达式:

git ls-files -- '*.js' '*.py'

【讨论】:

    【解决方案2】:

    不。从 git 版本 2.20.1 开始

    git ls-files -- '**/*.js' '**/*.py'
    

    不会返回任何文件

    git ls-files -- '**/*.js'
    

    将返回 repo 中的所有 .js 文件

    【讨论】:

      猜你喜欢
      • 2019-06-01
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多