查找修改与GIT存储库中的模式匹配的文件名的提交 [英] Find commits that modify file names matching a pattern in a GIT repository
问题描述
我想在我的代码库中找到添加视频文件以将其丢弃的提交. 有没有办法在git中查找这些文件?
I'd like to find commits in my code base that add video files to throw them out. Is there a way to look for these files in git ?
例如,假设所有视频的文件名都以扩展名.wmv结尾;我想查找所有引入这些文件的提交,并通过修复程序或类似的东西摆脱它们.
For example let's say all videos have a filename ending with the extension .wmv ; I'd like to find all commits introducing these files and get rid of them with a fixup or something.
有什么想法吗?
推荐答案
您可以将git log
与pathspec一起使用:
you can use git log
with a pathspec:
git log --all -- '*.wmv'
这将使您获得对.wmv文件进行更改的所有提交.是的,它也将下降到子目录中(但是您必须用单引号括住pathspec,因此它将按原样传递给git).
this will get you all commits which make changes to .wmv files. yes, this will descend into subdirectories too (but you have to surround your pathspec with single quotes, so it will be passed as is to git).
如果您只对提交哈希(脚本等)感兴趣,请直接使用git rev-list
机制:
if you are only interested in commit hashes (scripting etc.) use the git rev-list
machinery directly:
git rev-list --all -- '*.wmv'
这篇关于查找修改与GIT存储库中的模式匹配的文件名的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!