How to get a list of all blobs in a repository in Git

后端 未结 3 906
無奈伤痛
無奈伤痛 2021-01-18 17:51

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

3条回答
  •  抹茶落季
    2021-01-18 18:40

    First of all, there's very little chance you want to do this by listing blobs. A blob is just raw data; it doesn't know what file it's part of. The true answer depends a little bit on what exactly you're trying to accomplish. For example, do you need to search blobs that are part of commits which aren't even accessible from the commit history? If you don't, here are a couple thoughts.

    Perhaps the pickaxe search of git-log would do what you want:

    -S Look for differences that introduce or remove an instance of . Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.

    Depending on your end goal, this might be way better than what you suggested - you'll actually see how the string was added or removed. You can of course use the information you get to cat the entire file, if you so desire.

    Or maybe you want to list revisions with git-log and use git-grep on the trees (commits) it provides?

提交回复
热议问题