Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT LFS: Get the complete list from the whole repository

Tags:

git

git-lfs

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?

like image 919
Emeric Verschuur Avatar asked Sep 11 '17 12:09

Emeric Verschuur


People also ask

How do I use Git LFS with my existing repository?

Once Git LFS is installed, you need to associate it with a large file in your repository. If there are existing files in your repository that you'd like to use GitHub with, you need to first remove them from the repository and then add them to Git LFS locally.

How does Git LFS handle large files?

Specifically, large files are downloaded during the checkout process rather than during cloning or fetching. Git LFS does this by replacing large files in your repository with tiny pointer files.

How do I use existing files in my repository with GitHub?

If there are existing files in your repository that you'd like to use GitHub with, you need to first remove them from the repository and then add them to Git LFS locally. For more information, see " Moving a file in your repository to Git LFS ."

What is the OID of a Git LFS file?

Note that each Git LFS file is indexed by its SHA-256 OID; the paths that reference each file are not visible via the UI. This is because there could be many different paths at many different commits that may refer to a given object, so looking them up would be a very slow process.


2 Answers

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.

like image 196
FearlessHyena Avatar answered Oct 26 '22 18:10

FearlessHyena


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.

like image 3
Svend Hansen Avatar answered Oct 26 '22 16:10

Svend Hansen