35

I'm not sure if this is the right forum to discuss git-lfs but as we have a tag for it I'll post my question. I have read the "Troubleshoot Git LFS in Bitbucket" page.

I'm getting the following error when runing:

ssh-agent bash -c 'ssh-add /home/dan/.ssh/keyname;  git clone git@bitbucket.org:[repo name removed].git' 

$ git-lfs smudge -- [Filename removed].zip Error downloading object: [Filename removed].zip ([code removed]): Smudge error: Error downloading [Filename removed].zip ([code removed]): [[code removed] Object does not exist on the server: [404] Object does not exist on the server

[404] Object does not exist on the server github.com/git-lfs/git-lfs/errors.newWrappedError /tmp/docker_run/src/github.com/git-lfs/git-lfs/errors/types.go:170: [[code removed]] Object does not exist on the server github.com/git-lfs/git-lfs/errors.newWrappedError /tmp/docker_run/src/github.com/git-lfs/git-lfs/errors/types.go:170: Error downloading [Filename removed].zip ([code removed]) github.com/git-lfs/git-lfs/errors.newWrappedError /tmp/docker_run/src/github.com/git-lfs/git-lfs/errors/types.go:170: Smudge error

Has anyone got any advice?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Dan-Dev
  • 8,957
  • 3
  • 38
  • 55

2 Answers2

55

I eventually found an answer by strich: on https://github.com/git-lfs/git-lfs/issues/911

I've had similar issues in the past and I think there may be a potential bug in cloning with git lfs (Still to be determined). You can try this method of fetching the repo, which is in fact faster too:

// Skip smudge - We'll download binary files later in a faster batch
git lfs install --skip-smudge

// Do git clone here
git clone ...

// Fetch all the binary files in the new clone 
git lfs pull

// Reinstate smudge
git lfs install --force 

This only needs to be done once to initialize the clone for the first time.

Please do test it and let me know if it fixes it.

ian
  • 12,003
  • 9
  • 51
  • 107
Dan-Dev
  • 8,957
  • 3
  • 38
  • 55
  • 2
    I can't say I fixed this. Eventually I gave up as I got other errors. – Dan-Dev Oct 04 '17 at 16:09
  • If you don't want to give up and re-download the whole repository, check this question: https://stackoverflow.com/questions/43989902/git-pull-smudge-filter-lfs-failed (especially the answer about `lfs.url` configuration option). – Tomasz Gandor May 17 '18 at 09:38
  • 2
    direct link to the github answer https://github.com/git-lfs/git-lfs/issues/911#issuecomment-169998792 – Deepak Bandela Jun 03 '20 at 07:31
  • If you have submodules: `git submodule foreach git lfs pull` – vsp Mar 09 '23 at 15:29
24

This corruption can happen due to another developer's misconfigured git-lfs that pushed to the repository, or sometimes due to some unusual failure during a push. Try re-sending the missing object (using its object ID) from a working tree:

git lfs push --object-id <remote> <oid>

The OID should be in the Smudge error message.

Danger
  • 251
  • 2
  • 3
  • 1
    Wow, I didn't expect this, but this worked for me. Maybe in the original lfs push the file didn't send through properly (used sourcetree originally). Thanks P.S. idk why people downvoted this, it actually helped me – ffarhour Nov 21 '19 at 22:37
  • I tried the command. However, a new clone still fails. Maybe it's a problem of our Gitlab. – ElpieKay Dec 02 '20 at 06:57
  • It turns out that our Gitlab has a wrong lfs setting. The lfs data are not synced between machines as expected. – ElpieKay Dec 02 '20 at 09:08
  • @ElpieKay can you please expand more on the fix for you? I encountered the same issue, the command above works, but I feel it is more of a workaround. It should work without having to manually push the object id. – George Cimpoies Dec 17 '20 at 12:07
  • @GeorgeCimpoies We have two machines that hold repository data. One for push and fetch, and the other for fetch only. By the previous settings, the lfs data on the push-and-fetch machine was not synced to the other. When a user happened to fetch from the other machine, the data was just unavailable. – ElpieKay Dec 17 '20 at 12:13
  • 5
    This worked for one object, but on my project there ended up being hundreds of objects that needed pushing. For that, `git lfs push --all` uploaded all objects. – Chris Hayes Apr 30 '21 at 14:23