Your push was rejected because an LFS pointer pointed to a file that does not exist

I’m trying to figure out what happened here – I was following the custom handler tutorial (Create custom Inference Handler). I cloned philschmid/distilbert-base-uncased-emotion, as instructed, and logged in to my HF account. I noticed the handler was complete already, so I went ahead and pushed to my new (private) repo. Unfortunately:

git push -f
Enumerating objects: 69, done.
Counting objects: 100% (69/69), done.
Delta compression using up to 8 threads
Compressing objects: 100% (65/65), done.
Writing objects: 100% (69/69), 118.91 KiB | 7.93 MiB/s, done.
Total 69 (delta 25), reused 0 (delta 0), pack-reused 0
remote: Scanning LFS files for validity, may be slow...
remote: -------------------------------------------------------------------------
remote: Your push was rejected because an LFS pointer pointed to a file that does not exist.
remote: For instance, this can happen if you used "git push --no-verify" to push your changes.
remote: Offending file: flax_model.msgpack
remote: -------------------------------------------------------------------------
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to ''

I never ran git push --no-verify. I see there was a flax_model.msgpack in Phil’s repo but it was deleted (Delete flax_model.msgpack · philschmid/distilbert-base-uncased-emotion at 3390c8d). I can’t find any remaining reference to it.

I worked around this with Repo_duplicator - a Hugging Face Space by osanseviero. I’d still like to understand why the error happened.

Hi @joelb, could you try again cloning philschmid/distilbert-base-uncased-emotion with those 2 steps:

git clone
git lfs fetch --all

And then try pushing to your own repo? This should fix the issue you encountered.

When you’re pushing to a different repository than the one you got your objects from, you need to upload those objects to the new repository, even if they’ve been deleted - what git lfs fetch --all does is that it pulls all the files, even the ones deleted. Those deleted files are part of the repo history, and someone could clone the second repository and need to check out an old version, so we need to upload them.

Thanks @pierric!