Chat Dp
Chat Dp

Reputation: 627

How to get git lfs files (original files not file pointers) from download as source code.zip from tags or releases?

When I tag the commit then I download from github.com/user/project/releases all LFS file is not coming (original files) but only the file pointers (around 1kb per file)

I tried to call "git lfs fetch" is absolute doesn't work because '.git' folder is not coming with the zip

$ git lfs fetch
Not in a git repository.

When I download the tag through the github.com/user/project/releases it should be the all original file from that tag.

Did I miss something? I tried to search at Google but not found my question.

Upvotes: 4

Views: 7158

Answers (2)

VonC
VonC

Reputation: 1325027

It is possible with GitLab 13.6 (November 2020)

Include Git LFS files in repository archive

Git Large File Storage (LFS) is one of Git’s solutions to handle large files; it replaces large files with text pointers while storing the file contents on a remote server (like GitLab).
It allows developers to version very large files with Git and keep Git operations between a local host and a server speedy and performant.

Downloading the source archive of a project that contains LFS files from GitLab used to export a pointer to the file instead of the file itself.
This made the archives smaller, but the archive would not hold a complete snapshot of the repository.

Having an incomplete repository generally meant more manual work to add those LFS files individually to have an accurate export of the repository.

GitLab 13.6 will now export the LFS files instead of the pointer to the files, making it seamless to export the contents of your repository.

See Documentation and Issue.

Upvotes: 3

bk2204
bk2204

Reputation: 76569

GitHub doesn't provide a way to get the LFS files using the downloadable archives. Some projects include their own tarballs that contains the LFS files, and if so, you can use one of those tarballs.

Otherwise, you can do something like the following to get the LFS files (in this case, for example/project at v1.0.0):

git clone -b v1.0.0 --depth 1 https://github.com/example/project.git project
git -C project archive --format=zip --prefix=project-1.0.0/ HEAD >project-1.0.0.zip

Note that if you're trying to download multiple archives, it will be better to clone the entire repo instead of using a shallow clone as I did above.

Upvotes: 2

Related Questions