Git LFS: Get the complete list from the whole repository

47.1k views Asked by At

I have only found git lfs ls-files but this command give only the list from a specific ref.

There is a way to have the whole list of LFS object from a Git repository?

4

There are 4 answers

2
FearlessHyena On BEST ANSWER

You can do this in Git LFS v2.4.0 and later using the --all flag

git lfs ls-files --all

You can read more about it in this pull request.

4
Marcelo Ávila de Oliveira On

The "git lfs ls-files" command can't list all LFS objects for the repository the way you want. The command need to list the LFS objects for a specific reference. It's easy to understand why it can't do that if you remember that each reference represent a snapshot of the repository history. The same behaviour happens with the "git ls-files" command, you can't list all files for all repository revisions (commits) at the same time.

4
Svend Hansen On

If you have access to the git LFS server, you can look in the lfs/objects folder. Is should contain a folder structure that works like a search tree for the stored objects. At some level (maybe third?) are the objects themselves.

A small example with a tiny project I just converted to git (and git lfs) to test this looks like this:

$ ls lfs/objects/*/*
lfs/objects/9f/ef:
9fef0fcd855a78effd175cdf5a49a14b57334b40f1ad0c75317d6cbc0bb29595

lfs/objects/a5/f2:
a5f207bf721d3cbf62d298b6e2c9fa7cbdb3e37c7f44590a6c8be76560d7b9d7

lfs/objects/ca/63:
ca631009296d9de54dde2f70fec997aa0b22f624ed8f6fecc763c684317ba825

In my case this is inside the .git folder. I haven't pushed it to a git LFS server, but I presume the structure is the same on there. This should (as far as I can tell) give you all the hashes (as the file names) of all the files stored in git LFS.

Note: I'm basing this on experimenting with git LFS and noting what happens. Not from any deeper understanding on how the storage system behind git LFS works.

0
Emeric Verschuur On

I have added an issue on the GIT LFS Github: https://github.com/git-lfs/git-lfs/issues/2575