How can I list all versions of all files in a git repository?
(For example for listing all files that ever contained a certain string)
This list could be use
This is how I get a list of SHAs and filenames for all the blobs in a repository:
$ git rev-list --objects --all | git cat-file --batch-check='%(objectname) %(objecttype) %(rest)' | grep '^[^ ]* blob' | cut -d" " -f1,3-
Notes:
The %(rest)
atom in the format string appends the rest of the input line after the object's SHA to the output. In this case, this rest happens to be the path name (for tree and blob objects).
The grep
pattern is intended to match only actual blobs, not tree objects which just happen to have the string blob
somewhere in their path name.