使用 git 查看子目录中与特定文件扩展名相关的所有日志
Using git to see all logs related to a specific file extension within subdirectories
我正在尝试查看存储库历史记录中的提交,但仅限于具有特定扩展名的文件。
如果这是目录结构:
$ tree
.
├── a.txt
├── b
└── subdir
├── c.txt
└── d
这是完整的历史:
$ git log --name-only --oneline
a166980 4
subdir/d
1a1eec6 3
subdir/c.txt
bc6a027 2
b
f8d4414 1
a.txt
如果我想查看扩展名为 .txt 的文件的日志:
$ git log --oneline *.txt
f8d4414 1
它returns只有当前目录中的文件,而不是子目录中的文件。我想在当前目录中包含所有可能的子目录。
我也试过:
$ git log --oneline */*.txt
1a1eec6 3
并且:
$ git log --oneline *.txt */*.txt
1a1eec6 3
f8d4414 1
这适用于这种情况,但对于更一般的情况并不实用。
并且:
$ git log --oneline HEAD -- *.txt
f8d4414 1
没有成功。
尝试:
git log --oneline -- '*.txt'
--
用于指示后面只跟有位置参数。 '*.txt'
搜索当前目录下的所有文件夹。
或者,您可以通过在子目录中开始搜索来限制结果,例如-- 'sub/*.txt'
.
我正在尝试查看存储库历史记录中的提交,但仅限于具有特定扩展名的文件。
如果这是目录结构:
$ tree
.
├── a.txt
├── b
└── subdir
├── c.txt
└── d
这是完整的历史:
$ git log --name-only --oneline
a166980 4
subdir/d
1a1eec6 3
subdir/c.txt
bc6a027 2
b
f8d4414 1
a.txt
如果我想查看扩展名为 .txt 的文件的日志:
$ git log --oneline *.txt
f8d4414 1
它returns只有当前目录中的文件,而不是子目录中的文件。我想在当前目录中包含所有可能的子目录。
我也试过:
$ git log --oneline */*.txt
1a1eec6 3
并且:
$ git log --oneline *.txt */*.txt
1a1eec6 3
f8d4414 1
这适用于这种情况,但对于更一般的情况并不实用。
并且:
$ git log --oneline HEAD -- *.txt
f8d4414 1
没有成功。
尝试:
git log --oneline -- '*.txt'
--
用于指示后面只跟有位置参数。 '*.txt'
搜索当前目录下的所有文件夹。
或者,您可以通过在子目录中开始搜索来限制结果,例如-- 'sub/*.txt'
.