A file says “version https://git-lfs.github.com/spec/v1” instead of its contents: fixing Git LFS pointer files
Git LFS (Large File Storage) keeps big files out of the git history. The repository only stores a three-line <i>pointer</i>, and the real file is downloaded separately. If that download never happened, you get the pointer instead: a 130-byte text file where your image, model or zip should be.
What a pointer looks like
version https://git-lfs.github.com/spec/v1
oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393
size 1328447The oid is the SHA-256 hash of the real file and size is its size in bytes. The URL is only a version label; nothing is fetched from it. Programs that open the pointer by mistake give confusing errors:
| Program | Error |
|---|---|
| PyTorch / pickle | UnpicklingError: invalid load key, 'v'. (the v of version) |
| Pillow | cannot identify image file |
| unzip, Python zipfile | not a zip file or End-of-central-directory signature not found |
| Browsers, games, image viewers | A broken image, or a file “in an unsupported format” |
Not sure what you’re looking at? Paste the first lines into What is this? or just open the file in a text editor.
The fix
git lfs install # once per user account; sets up the git hooks
git lfs pull # downloads the real files for the current checkout
git lfs ls-files # * = real file present, - = still a pointerIf git lfs isn’t a command, install the package first: apt install git-lfs, dnf install git-lfs, brew install git-lfs, or the Git for Windows installer (it’s included).
Why it happened, and the fix for each case
| Situation | Fix |
|---|---|
| Git LFS wasn’t installed when you cloned | git lfs install then git lfs pull in the existing clone; no need to clone again |
GIT_LFS_SKIP_SMUDGE=1 is set (often on purpose, to clone fast) | git lfs pull when you want the files, or git lfs pull --include "models/*.bin" for just some |
| Downloaded the repository as a ZIP from the website | Archives often contain pointers only, unless the owner turned on LFS objects in archives. Clone with git instead |
| GitHub Actions | Add with: lfs: true to the actions/checkout step. Other CI systems have a similar option, or run git lfs pull after checkout |
Inside docker build | The build only copies what’s on disk. Run git lfs pull before building, or the image ships pointers |
| This repository is over its data quota or bandwidth exceeded | The host’s LFS allowance ran out. Nothing to fix locally; the owner needs to free space or add more, or you get the files another way |
Smudge error or Object does not exist on the server | Someone committed a pointer without pushing the file: they need to run git lfs push --all origin |
Check you got the real file
The pointer’s oid is the SHA-256 of the real file, so you can confirm the download:
sha256sum model.bin # Linux
shasum -a 256 model.bin # macOS
Get-FileHash model.bin # PowerShell (SHA-256 by default)The hash generator explains SHA-256 and lets you hash text right in the page.
The opposite: “files that should have been pointers”
Encountered 3 file(s) that should have been pointers, but weren't means a file matches an LFS rule in .gitattributes (like *.psd filter=lfs diff=lfs merge=lfs -text) but was committed as a normal file, usually before the rule existed or from a machine without LFS. Fix it going forward with git add --renormalize . and a commit. Moving old history into LFS needs git lfs migrate import, which rewrites commits, so agree it with everyone who uses the repo first.
Related
Git says not a git repository when you run git lfs pull? You’re in the wrong folder: see fatal: not a git repository. Big downloads filling your disk: ENOSPC: no space left on device. Want to see exactly what changed between two text files? Use the text diff.
Questions
Why does my file contain version https://git-lfs.github.com/spec/v1?
It's a Git LFS pointer. The repository stores large files separately, and the real file was never downloaded, usually because Git LFS wasn't installed when you cloned. Run git lfs install and then git lfs pull.
Do I need to clone again to get the LFS files?
No. In the existing clone, run git lfs install once and then git lfs pull.
How do I get Git LFS files in GitHub Actions?
Set lfs: true on the actions/checkout step, or run git lfs pull after checking out.
Why does torch.load say invalid load key 'v'?
The model file is a Git LFS pointer, which starts with the word version. Download the real file with git lfs pull and try again.
Published .