如何使用git中的glob匹配选择多个文件类型

问题描述 投票:0回答:2

我有以下内容:

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

我想使用以下内容

[git ls-files -- {}其中{}是某种形式的glob模式

并且我希望它返回

bar/foo.js
bar/foo.py
baz.py
git glob
2个回答
1
投票

您可以在ls文件之后提供任意数量的glob表达式:

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

0
投票

不。从git版本2.20.1开始

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

将不返回任何文件

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

将返回仓库中的所有.js文件

© www.soinside.com 2019 - 2024. All rights reserved.