Find commits that modify file names matching a pattern in a GIT repository

Viewed 17817

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 ?

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.

Any ideas ?

7 Answers

To just view the commit hashes and the relevant file names for each commit you can use:

git rev-list --all -- '*.wmv' $1 | while read x; do git diff-tree --name-only -r $x; done | grep -E '((\.wmv$)|(^[^\.]+$))'

This will print out the commit hash followed by any filenames that matching the search string.

Related