jwm
jwm

Reputation: 5030

How to download git-lfs files using the oid sha256 information

I came across a set of images (e.g., https://github.com/kehuantiantang/A-DNN-based-Semantic-Segmentation-for-Detecting-Weed-and-Crop/blob/master/stuttgart/stuttgart_cp_00000.npy) that are stored in the git lfs with the information like this:

version https://git-lfs.github.com/spec/v1
oid sha256:6692f38904c1ae21cd3d3e6e378538c07fda86fe97ee01d8664bb95fc20cd1de
size 8889498

How to view and download the original image file? I am new to Git LFS. Any one can give some detailed steps to follow?

Updates on what I did:

I downloaded the github repo: https://github.com/kehuantiantang/A-DNN-based-Semantic-Segmentation-for-Detecting-Weed-and-Crop

unzipped it to a folder, and cd to the subfolder stuttgart(here is what are included:https://github.com/kehuantiantang/A-DNN-based-Semantic-Segmentation-for-Detecting-Weed-and-Crop/tree/master/stuttgart),

type the command git lfs pull (via git bash win10), but got this error: "batch response:Rate limit exceeded: https://github.com/kehuantiantang/A-DNN-based-Semantic-Segmentation-for-Detecting-Weed-and-Crop.git/info/lfs/objects/batch error: failed to fetch some objects from 'https://github.com/kehuantiantang/A-DNN-based-Semantic-Segmentation-for-Detecting-Weed-and-Crop.git/info/lfs'

Upvotes: 11

Views: 18826

Answers (4)

Jhonny Ramirez Zeballos
Jhonny Ramirez Zeballos

Reputation: 3156

1. First Install:

git lfs install

2. Fetch all LFS:

git lfs fetch --all

fetch: 3 object(s) found, done
fetch: Fetching all references...
Downloading LFS objects: 100% (3/3), 468 MB | 2.4 MB/s

3. Get object list:

git lfs ls-files --all

979bb1f94f - Path/dump-01-11-2022.sql
a0d4f0ef25 - Path/dump-01-06-2022.sql
c01c32ecf8 - Path/dump-01-10-2022.sql

4. Get SHA-256 OID:

git log --all -p -S a0d4f0ef25

commit bb6a2b3381bb2f2751cf9a6db679d99dc628f14c (tag: 3.14.98)
Author: Jhonny Cinco <[email protected]>
Date:   Tue Jan 11 14:50:45 2022 -0400

     [LFS] Update sql script

5. Get file:

git checkout bb6a2b3381bb2f2751cf9a6db679d99dc628f14c

HEAD is now at bb6a2b3 [LFS] Update sql script

Upvotes: 2

Syed Sajjad Askari
Syed Sajjad Askari

Reputation: 61

If this is in a repository, you should be able to run git lfs install on your system and then check out the files by using git lfs pull. In the future, LFS files will be pulled down automatically after you've run git lfs install once.

If it's not in a repository, then you'll have to find the LFS server and make your own API request to download it. The pointer file doesn't tell you anything about the server on which the LFS file is located, only the object that's being referenced.

Upvotes: 1

wcw
wcw

Reputation: 64

You can use

git log -p -S6692f38904c1ae21cd3d3e6e378538c07fda86fe97ee01d8664bb95fc20cd1de

to get the file path, then

git lfs fetch -I [filePath]

Upvotes: 2

amimibear
amimibear

Reputation: 29

No need for oid sha256.

git lfs fetch git lfs checkout is ok.

Upvotes: 2

Related Questions