# Fix Git LFS Object Download Failed for Large Files

You clone a repository that uses Git LFS (Large File Storage), but when you checkout the files, you get placeholder text instead of the actual file content:

bash
version https://git-lfs.github.com/spec/v1
oid sha256:abc123...
size 52428800

Or during a pull:

bash
batch request: missing: 3 objects
Error downloading object: models/model-v2.bin (abc1234): Smudge error

Git LFS replaces large files with pointer files in the repository. The actual file content is stored on a separate LFS server and downloaded on demand.

Step 1: Install Git LFS

If Git LFS is not installed, pointer files are never resolved:

bash
git lfs version

If not installed:

```bash # Debian/Ubuntu sudo apt install git-lfs

# macOS brew install git-lfs

# Install the Git LFS hooks git lfs install ```

The git lfs install command sets up the smudge and clean filters that automatically download LFS objects when checking out files.

Step 2: Fetch LFS Objects

If Git LFS is installed but files are still pointers:

bash
git lfs fetch --all
git lfs checkout

The fetch --all downloads all LFS objects from the remote. The checkout replaces pointer files with actual content.

Step 3: Check LFS Server Connectivity

LFS objects are downloaded from a separate server. Verify connectivity:

bash
git lfs env

This shows the LFS endpoint:

bash
LocalWorkingDir=/path/to/repo
LocalGitDir=/path/to/repo/.git
Endpoint=https://github.com/user/repo.git/info/lfs (auth=none)
LocalStorageDir=/path/to/repo/.git/lfs/objects

Test the endpoint:

bash
curl -I https://github.com/user/repo.git/info/lfs

If the endpoint requires authentication:

```bash # For GitHub git config --global lfs.https://github.com.access basic

# For GitLab git config --global lfs.https://gitlab.com.access basic ```

Step 4: Retry Failed Downloads

If some objects failed to download:

```bash # Show which objects are missing git lfs status

# Retry downloading git lfs fetch origin git lfs checkout ```

For specific files:

bash
git lfs pull --include="models/*.bin,videos/*.mp4"

Step 5: Large File Transfer Issues

For very large LFS objects (several GB), the download may timeout:

```bash # Increase timeout GIT_CURL_VERBOSE=1 git lfs fetch --all

# Configure larger buffer git config --global http.postBuffer 524288000 git config --global lfs.concurrenttransfers 3 ```

Reducing concurrenttransfers from the default (8) to 3 uses less bandwidth per transfer, which can help on unstable connections.

Step 6: LFS Object Not Found on Server

If the LFS server reports an object is missing:

bash
batch response: Object not found: abc1234

This means the LFS object was never pushed to the server, or was garbage collected. Check:

```bash # Verify LFS objects locally git lfs ls-files

# Check if the object exists in the local store git lfs fsck ```

If fsck reports missing objects, the data is lost from the LFS server. Recovery options:

  1. 1.Ask a team member who has the file to push the LFS object:
  2. 2.```bash
  3. 3.# On their machine:
  4. 4.git lfs push --all origin
  5. 5.`
  6. 6.If you have a backup of the original file, re-add it:
  7. 7.```bash
  8. 8.git lfs track "*.bin"
  9. 9.git add models/model-v2.bin
  10. 10.git commit -m "Re-add LFS object"
  11. 11.git push
  12. 12.`

Step 7: Clone With LFS in One Step

To avoid the pointer file issue entirely, always clone with LFS:

bash
GIT_LFS_SKIP_SMUDGE=0 git clone https://github.com/user/repo.git
cd repo
git lfs pull

Or use the standard clone (LFS fetches automatically):

bash
git clone https://github.com/user/repo.git
cd repo
# LFS files are automatically downloaded if git-lfs is installed

Step 8: Shallow Clone With LFS

Shallow clones (--depth 1) can miss LFS objects from older commits:

bash
git clone --depth 1 https://github.com/user/repo.git
cd repo
git lfs fetch --all  # May fail for objects not in HEAD

For full LFS support, avoid shallow clones or ensure all needed LFS objects are in the latest commit.