DENIED update refs/heads/main: forbidden

I followed the instructions shown immediately upon creating a huggingface space; however, I cannot push any changes I make to the cloned space git repo.
If I try I will get the following:

Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 414 bytes | 414.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: ----------------------------------------------------------
remote: Your push was rejected for the following reasons:
remote: DENIED update refs/heads/main: forbidden
remote: ----------------------------------------------------------
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to ''

I have tried searching this error, but I could not find anything helpful. If someone could point me in the right direction thank you.

1 Like

I am facing the same issue. Were you able to resolve this?

have you tried git push --force ?

I am pushing this model from colab. How do I use this from the trainer.push_to_hub()?

I see, we don’t support the force push yet on push_to_hub(). If you’re on colab, can you found out the dir of your Trainer? then run this shell command on a cell. I hope after that, you might not have issues with trainer.push_to_hub()

!cd trainer_folder && git push --force

I think for me my issue was using incorrect credentials for my huggingface account, as I was able to push successfully following the original instructions after I reset my account password.

1 Like

I had the same error messages, turns out it was because I was using a “read” token instead of a “write” one.


Thank you!!!

@radames I was having this problem with this following errors can’t push my files to hugging face ,I was having following error

I was using write token only but I was getting this error…pls anyone help me out


hi @sushmanth ,

Can you please try to lfs track the .onnx then add push then?

git lfs track "*.onnx"
git add *.onnx
git commit -a
git push

Please let me know if that works . You can read more about it here and here

1 Like

@radames ,I was using this .yml file ,I don’t knew where iam going wrong once u pls check this out

@radames I was using GitHub workflow to deploy into hugging face ,so I don’t knew where I was going wrong…

i have done git lfs install, also done git track “.dll" and ".lib”, then also not able to push to my new spaces

Hi @Jignasha, you might need to clean up the git history, since you may have committed these .dll and .libs files before you started tracking them with LFS

cleared git history, did git lfs install, gilt lfs track *.dll and *.lib, git lfs track *.pyd, not updating to spaces
issue is not resolving, taking a lot of time

hi @jignasha , you have offending files .pyd these are compiled python binaries, they don’t need to be on your commit, please add it to your .gitignore and cleanup the files from your history. I hope that works now

second link was a life save, thank you so much!

1 Like