查找修改与GIT存储库中的模式匹配的文件名的提交 [英] Find commits that modify file names matching a pattern in a GIT repository

查看:103
本文介绍了查找修改与GIT存储库中的模式匹配的文件名的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的代码库中找到添加视频文件以将其丢弃的提交. 有没有办法在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆