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

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.

  • Git diff fails on file with underscore in path
  • Git character encoding with Spanish characters
  • Git wrongly interprets that files names have changed after I pull
  • how do I clone files with colons in the filename
  • Git pull error: unable to create file (Invalid argument)
  • How do you specify git URLs with spaces on Windows under cygwin?
  • Any ideas ?

  • What exactly does the ReCommit feature in TortoiseGit do?
  • Git clone with all branches
  • apparently same commits give different sha1, why?
  • How to delete a file tracked by git-lfs and release the storage quota?
  • With Github, is it possible to see what a file looked like at a certain commit, and not just the diff?
  • Git push existing repo to a new and different remote repo server?
  • 6 Solutions collect form web for “Find commits that modify file names matching a pattern in a GIT repository”

    you can use git log with a pathspec:

    git log --all -- '*.wmv'

    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).

    if you are only interested in commit hashes (scripting etc.) use the git rev-list machinery directly:

    git rev-list --all -- '*.wmv'

    If you want to remove these files from all your commits, consider rewriting the entire history with the filter-branch command. E.g.,

    git filter-branch --index-filter 'git rm --cached --ignore-unmatch -r *.wml' HEAD

    You can try this:

    git log --follow *.wmv

    this will list all commits (with hash) that modified wmv files.

    Yup, like mentioned, I think the thinko is that removing the commits that introduce them is not going to remove the blobs

    See for an extensive treatment of the subject and examples

    If the goal is to remove the files from the repository (thus rewriting history), use the BFG Repo-Cleaner, e.g.:

    bfg --delete-files '*.wmv' --private --no-blob-protection

    If the files are relevant, you can keep them under version control using Git LFS. To migrate (also rewriting history), you do something such as:

    git-lfs-migrate \
        -s original.git  \
        -d converted.git \
        -l \

    To simply list or examine the commits, I refer to knittl’s answer:

    git rev-list --all -- '*.wmv'
    git log --all -- '*.wmv'

    This can work in gitk as well, using the View / New View / Enter files and directories to include, one per line box.

    But note that you need a wildcard that covers the path section of the filename, or else nothing will show.

    eg if you have had a file called, with a varied life (!) appearing in different places in the file tree and you want to see all versions, then you must specify:

    Git Baby is a git and github fan, let's start git clone.