我试图查看存储库历史记录中的提交,但仅针对具有特定扩展名的文件.
如果这是目录结构:
$ tree
.
??? a.txt
??? b
??? subdir
??? c.txt
??? d
Run Code Online (Sandbox Code Playgroud)
这是完整的历史:
$ git log --name-only --oneline
a166980 4
subdir/d
1a1eec6 3
subdir/c.txt
bc6a027 2
b
f8d4414 1
a.txt
Run Code Online (Sandbox Code Playgroud)
如果我想查看扩展名为.txt的文件的日志:
$ git log --oneline *.txt
f8d4414 1
Run Code Online (Sandbox Code Playgroud)
它仅返回当前目录中的文件,而不返回子目录中的文件.我想在当前目录中包含所有可能的子目录.
我也尝试过:
$ git log --oneline */*.txt
1a1eec6 3
Run Code Online (Sandbox Code Playgroud)
和:
$ git log --oneline *.txt */*.txt
1a1eec6 3
f8d4414 1
Run Code Online (Sandbox Code Playgroud)
这适用于这种情况,但对于更通用的情况则不实用.
和:
$ git log --oneline HEAD -- *.txt
f8d4414 1
Run Code Online (Sandbox Code Playgroud)
没有成功.
sfl*_*che 15
尝试:
git log --oneline -- '*.txt'
Run Code Online (Sandbox Code Playgroud)
将--用于指示只定位参数也会随之而来.并'*.txt'从当前目录中搜索所有文件夹.
或者,您可以通过在子目录中开始搜索来限制结果,例如-- 'sub/*.txt'.
| 归档时间: |
|
| 查看次数: |
3041 次 |
| 最近记录: |