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: -------------------------------------------------------------------------
To https://huggingface.co/joelb/distilbert-tutorial
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://huggingface.co/joelb/distilbert-tutorial'

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.

2 Likes

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 https://huggingface.co/philschmid/distilbert-base-uncased-emotion
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!

Hi@pierric, sorry but this doesn’t solve it. Any idea why the error is occurring? I know that if I add those file extension in .gitattributes (*. msgpack in this case for the example above) then it works. But I don’t want simple files and text files to be treated as LFS.

A very late reply, but I’m just leaving this for anyone else who might be looking for a solution. In my case, tokenizer.json points to another tokenizer.json (with a specififc hash). And since the repo is completely empty, the tokenizer.json is invalid.

1 Like