Can't Push to New Space

I’m getting the following errors when trying to push to my new space for the first time.

remote: -------------------------------------------------------------------------
remote: You are not authorized to push to this repo.
remote: Make sure that you are properly logged in.
remote: -------------------------------------------------------------------------
To https://huggingface.co/spaces/Grokgpt/grokgpt
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://huggingface.co/spaces/Grokgpt/grokgpt'

I am logged in with a write token. I don’t have any large files, but I did activate lfs. I have huggingface_hub installed and huggingface-cli. I get the following output from cli whoami.

(hf-grokgpt) larry@Larrys-MacBook-Pro grokgpt % huggingface-cli whoami
Grokgpt
**orgs:** grokgpt-org

I am folllowing the instructions on the Spaces page. I cloned the repo, created a Dockerfile, and did the following:

git add Dockerfile 
git commit -m "Add application file" 
git push

I’ve tried starting over from scratch several times. Still get the same error.

I have an SSH key. I have a GPG key. I’ve got 3 write tokens. I’ve restarted and reset my space a dozen times. Cloned it a dozen times. Here is my .git/config.

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = https://huggingface.co/spaces/Grokgpt/grokgpt
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
        remote = origin
        merge = refs/heads/main

Shouldn’t be this difficult to push to a repo. I’ve spent way too many hours of my life on it. Maybe I have something misconfigured, but can’t figure out what. Ready to give up on Huggingface spaces.

2 Likes

hi @Grokgpt ,

sorry you’re having issues, one note it seems like you’re on OSX, once had similar issue and it was due to my keychain access misconfigured.

One hack way to solve it is to add your token and user to your .git/config inside your repo

[remote "origin"]
        url = https://USER:TOKEN@huggingface.co/spaces/Grokgpt/grokgpt
        fetch = +refs/heads/*:refs/remotes/origin/*
4 Likes

Hi @Grokgpt, sorry for the inconvenience.

Can you do huggingface-cli login (press Enter to add to git credentials) and then huggingface-cli env and copy-paste the output of both commands please?

Thank you in advance

1 Like

(for context, pushing to Huggingface Hub using your SSH key is not yet possible but we are working on that feature)

1 Like

Thanks for getting back to me. I hadn’t gotten a response in awhile and I stopped checking for a day or two. I’ll give this a try!

Thanks, here’s the output:

(hf-grokgpt) larry@Larrys-MacBook-Pro grokgpt % huggingface-cli login

    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|
    
    A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.
    Setting a new token will erase the existing one.
    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token: 
Add token as git credential? (Y/n) y
Token is valid.
Your token has been saved in your configured git credential helpers (osxkeychain).
Your token has been saved to /Users/larry/.cache/huggingface/token
Login successful
(hf-grokgpt) larry@Larrys-MacBook-Pro grokgpt % huggingface-cli env

Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.13.3
- Platform: macOS-10.16-x86_64-i386-64bit
- Python version: 3.11.2
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /Users/larry/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: Grokgpt
- Configured git credential helpers: osxkeychain
- FastAI: N/A
- Tensorflow: N/A
- Torch: N/A
- Jinja2: N/A
- Graphviz: N/A
- Pydot: N/A
- Pillow: N/A
- hf_transfer: N/A
- ENDPOINT: https://huggingface.co
- HUGGINGFACE_HUB_CACHE: /Users/larry/.cache/huggingface/hub
- HUGGINGFACE_ASSETS_CACHE: /Users/larry/.cache/huggingface/assets
- HF_TOKEN_PATH: /Users/larry/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False

Whoa! That worked. Thanks!

1 Like

The hack worked. I didn’t try cleaning up the osxkeychain yet.

1 Like

FYI we now support SSH authentication,

example:

1 Like

I’m having the same issues not being able to write to a new HF space.

I’ve created a new token with write access, logged in via huggingface-cli and still am unable to write.

Here is the output of huggingface-cli env, I would prefer not to add username:token to the .git/config file.

C02D3C6NMD6M:hello-world dchau$ huggingface-cli login

    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|
    
    A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.
    Setting a new token will erase the existing one.
    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token: 
Add token as git credential? (Y/n) Y
Token is valid.
Your token has been saved in your configured git credential helpers (osxkeychain).
Your token has been saved to /Users/dchau/.cache/huggingface/token
Login successful
C02D3C6NMD6M:hello-world dchau$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 452 bytes | 452.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: -------------------------------------------------------------------------
remote: You are not authorized to push to this repo. 
remote: Make sure that you are properly logged in.
remote: -------------------------------------------------------------------------
To https://huggingface.co/spaces/ducchau/hello-world
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://huggingface.co/spaces/ducchau/hello-world'
C02D3C6NMD6M:hello-world dchau$ huggingface-cli env

Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.14.1
- Platform: macOS-13.2.1-x86_64-i386-64bit
- Python version: 3.11.3
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /Users/dchau/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: ducchau
- Configured git credential helpers: osxkeychain
- FastAI: N/A
- Tensorflow: N/A
- Torch: N/A
- Jinja2: N/A
- Graphviz: N/A
- Pydot: N/A
- Pillow: N/A
- hf_transfer: N/A
- gradio: N/A
- ENDPOINT: https://huggingface.co
- HUGGINGFACE_HUB_CACHE: /Users/dchau/.cache/huggingface/hub
- HUGGINGFACE_ASSETS_CACHE: /Users/dchau/.cache/huggingface/assets
- HF_TOKEN_PATH: /Users/dchau/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False
1 Like

hi @ducchau , thanks for sharing you env. I see you’re on OSX, and as you noticed on this thread there a few folks facing similar issue with OSX.
Perhaps you could try the SSH authentication approach? Hugging Face – The AI community building the future. ? If you add your keys to your settings you can edit the file from your .git/config or reclone the repo git clone git@hf.co:spaces/ducchau/hello-world

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = https://huggingface.co/spaces/ducchau/hello-world
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
        remote = origin
        merge = refs/heads/main

to

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[remote "origin"]
	url = git@hf.co:spaces/ducchau/hello-world
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
	remote = origin
	merge = refs/heads/main
1 Like

hi @radames I have the same error message on Linux when I try to push to a new space. I’m on Linux and I’m using SSH authentification.

My SSH authentification should be ok because I get

Hi antoinescenario, welcome to Hugging Face.

as output of ssh -T git@hf.co.

- Platform: Linux-5.15.0-1028-aws-x86_64-with-glibc2.35
- Python version: 3.10.6
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /home/ubuntu/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: antoinescenario
- Configured git credential helpers: store
- FastAI: N/A
- Tensorflow: 2.12.0
- Torch: 2.0.0
- Jinja2: 3.1.2
- Graphviz: N/A
- Pydot: N/A
- Pillow: 9.3.0
- hf_transfer: N/A
- ENDPOINT: https://huggingface.co
- HUGGINGFACE_HUB_CACHE: /home/ubuntu/.cache/huggingface/hub
- HUGGINGFACE_ASSETS_CACHE: /home/ubuntu/.cache/huggingface/assets
- HF_TOKEN_PATH: /home/ubuntu/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False

hi @antoinescenario ,
perhaps you have infringing files? we default to LFS for binary files, such as images, models, etc.
so if you’ve committed such file in the past and posteriorly track then with LFS, you will still get errors. In general you get a log message stating the problem on git push

hi @radames thanks for your answer. Yes I actually did that kind of things with binary files. But I managed to push with token authentification.

1 Like

cool! still weird you could’t use the SSH. I’m happy the token worked for you

This worked for me!

Just set up the SSH agent on my local machine, and manually chance the .git/config file from my repo, then everything worked!

1 Like

hi @radames, I am experiencing a similar problem in OSX.
I was able to push models directly into my space until I did some file reorganization and I have messed up some things, after hours of debugging I still can’t find what is happening.

After training, when pushing my model, I get the error:

Several commits (3) will be pushed upstream.
2023-10-08 16:36:17 huggingface_hub.repository WARNING: Several commits (3) will be pushed upstream.
The progress bars may be unreliable.
2023-10-08 16:36:17 huggingface_hub.repository WARNING: The progress bars may be unreliable.
EOF
error: failed to push some refs to 'https://huggingface.co/inesani/ner-test3'

The weird thing is it creates the model on the remote repository and is able to push some files related to the tokenizer but large files as training_args.bin and pytorch_model.bin are not…that’s why I think it might be related with lfs.
I have tried the hack of having my token into the .git/config but same thing happens. I have created many new Access Tokens and the issue is the same.

I am logged in without trouble:

(.venv) inesanibarro@Iness-MacBook-Pro ner-test2 % huggingface-cli login

    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|
    
    A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.
    Setting a new token will erase the existing one.
    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token: 
Add token as git credential? (Y/n) Y
Token is valid (permission: write).
Your token has been saved in your configured git credential helpers (osxkeychain,store).
Your token has been saved to /Users/inesanibarro/.cache/huggingface/token
Login successful
(.venv) inesanibarro@Iness-MacBook-Pro ner-test2 % huggingface-cli env

Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.15.1
- Platform: macOS-12.5-arm64-i386-64bit
- Python version: 3.10.9
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /Users/inesanibarro/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: inesani
- Configured git credential helpers: osxkeychain, store
- FastAI: N/A
- Tensorflow: N/A
- Torch: 2.0.1
- Jinja2: 3.1.2
- Graphviz: N/A
- Pydot: N/A
- Pillow: 9.5.0
- hf_transfer: N/A
- gradio: 3.33.1
- numpy: 1.24.3
- ENDPOINT: https://huggingface.co
- HUGGINGFACE_HUB_CACHE: /Users/inesanibarro/.cache/huggingface/hub
- HUGGINGFACE_ASSETS_CACHE: /Users/inesanibarro/.cache/huggingface/assets
- HF_TOKEN_PATH: /Users/inesanibarro/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False

Any help will be much appreciated!

hi @inesani ,

if you can push some files, then the error is not on the authentication side. perhaps the git history of your model is mixed with files that need to be lfs. Do you have more logs besides this? Can you confirm whether it is possible to push some files?

its not working for me . can someone help me with this
(base) adduser@HP-LPT:~/First/Minima$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 439 bytes | 439.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: -------------------------------------------------------------------------
remote: You are not authorized to push to this repo.
remote: Make sure that you are properly logged in.
remote: -------------------------------------------------------------------------
To Minima - a Hugging Face Space by SanaullahCh
! [remote rejected] main → main (pre-receive hook declined)
error: failed to push some refs to ‘Minima - a Hugging Face Space by SanaullahCh