# Push\_to\_hub usage errors?

**URL:** <https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132>\
**Category:** Beginners\
**Created:** [August 10, 2021, 2:03pm UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132 "2021-08-10T14:03:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheLongSentance](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/thelongsentance/32/2470_2.png) [@TheLongSentance](https://discuss.huggingface.co/u/TheLongSentance)\
**Post date:** [August 10, 2021, 2:03pm UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/1 "2021-08-10T14:03:43Z")

</div>

Trying to push my model back to the hub from python (not notebook) and failing so far:

I am using a T5 model with the latest development version of the example “run\_summarization.py” and pass a load of runtime parameters in and my model works fine. There are some parameters that seem to relate to pushing the model back to the hub which I have identified from the “run\_summarization.py -h” text:

- **–use\_auth\_token** - Will use the token generated when running `transformers-cli login` (necessary to use this script with private models). (default: False) -_I assume I need to set this True given I ran the cli and it saved my token in the cache?_
- **–push\_to\_hub** - Whether or not to upload the trained model to the model hub after training. (default: False) - _I set this to True_
- **–push\_to\_hub\_model\_id** - The name of the repository to which push the `Trainer`. (default: None) - \*I set this to a string that is my model like “my\_model” I guess? \*
- **–push\_to\_hub\_organization** - _Not relevant for me since I am an individual?_
- **–push\_to\_hub\_token** - _Not needed if I set --use\_auth\_token True_

So I have as part of my run time parameter list:

**–push\_to\_hub True --use\_auth\_token True --push\_to\_hub\_model\_id "t5\_tuesday"**

But I get the error:

**OSError: Tried to clone a repository in a non-empty folder that isn’t a git repository. If you really want to do this, do it manually:\mgit init && git remote add origin && git pull origin main or clone repo to a new folder and move your existing files there afterwards.**

As I said above, I did `transformers-cli login` successfully in my environment. I thought maybe I needed to do as I had seen in an example Colab notebook:

**!pip install hf-lfs**

**!git config --global user.email "\<my\_github\_email\>"**  
**!git config --global user.name "\<my\_github\_username\>"**

but after doing the above the error changes to:

**subprocess.CalledProcessError: Command ‘[‘git-lfs’, ‘–version’]’ returned non-zero exit status 1.**

But not sure if needed (I am guessing)! I can supply the Trace for both kinds of errors above if needed, but I don’t know what minimal configuration works running a .py file to see if I am being a dumb user and the problem is usage or the problem is something else.

Any help on correct usage appreciated or point me to a working example? Thanks!

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](https://discuss.huggingface.co/u/sgugger)\
**Post date:** [August 10, 2021, 3:52pm UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/2 "2021-08-10T15:52:11Z")

</div>

As the error indicates, you are trying to clone an existing repository in a folder that is not a git repository, so you should use an empty folder, or an ID for a new repository.

---

<div class="post-metadata">

**Author:** ![TheLongSentance](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/thelongsentance/32/2470_2.png) [@TheLongSentance](https://discuss.huggingface.co/u/TheLongSentance)\
**Post date:** [August 10, 2021, 6:00pm UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/3 "2021-08-10T18:00:08Z")

</div>

Sorry @sgugger , could you provide a bit more explanation please? I am no Github expert and other than the error message I didn’t know that I was trying to clone an existing repository, so I don’t know how to interpret the message at all (yes I am a numpty, sorry!). Could you point me to a runtime parameter configuration that I could expect to work? For example, the following doesn’t work and produces the same error relating to github:

–push\_to\_hub True --use\_auth\_token True --push\_to\_hub\_model\_id “t5\_tuesday”

My expectation from the above is that it should create and save my model as “t5\_tuesday” under my account as TheLongSentance/t5\_tuesday. Despite the error, this actually seems to happen on checking my huggingface account but I still get the github error within the run?

And do I need to do the two !git config statements?

And finally do I need to !pip install hf-lfs or is that not needed any more?

Thanks!

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](https://discuss.huggingface.co/u/sgugger)\
**Post date:** [August 11, 2021, 6:57am UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/4 "2021-08-11T06:57:08Z")

</div>

Change your `output_dir` or delete its content before re-running the script, or use `--overwrite_output_dir` to remove its content.

The problem is that you have a non-empty `output_dir` in which you are trying to clone an existing model.  
Also make sure you are on the latest version of the script and Transformers.

---

<div class="post-metadata">

**Author:** ![nickmuchi](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nickmuchi/32/29420_2.png) [@nickmuchi](https://discuss.huggingface.co/u/nickmuchi)\
**Post date:** [January 4, 2022, 2:08am UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/5 "2022-01-04T02:08:43Z")

</div>

hi, I am facing the same error when trying to pushtohubcallback… Logging in via the notebook was successful

---

<div class="post-metadata">

**Author:** ![Talha](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@Talha](https://discuss.huggingface.co/u/Talha)\
**Post date:** [August 3, 2022, 7:51pm UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/6 "2022-08-03T19:51:55Z")

</div>

I was logging in current folder like this

```auto
training_args = TrainingArguments(
  output_dir=".",

```

Changing it to

```auto
training_args = TrainingArguments(
  output_dir="./output",

```

resolved the issue

---

<div class="post-metadata">

**Author:** ![jmugan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jmugan/32/18562_2.png) [@jmugan](https://discuss.huggingface.co/u/jmugan)\
**Post date:** [August 15, 2023, 4:38am UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/7 "2023-08-15T04:38:43Z")

</div>

Same problem here. It’s unclear what is happening. I watched the video on this and this error didn’t come up, so it is hard to piece it all together. It seems like `push_to_hub` should just push it to hub.

Is there a sequence of steps that new users can follow? Something real basic that doesn’t leave anything out.

I’m on Colab if that makes a difference.

---

<div class="post-metadata">

**Author:** ![honzatoegel](https://avatars.discourse-cdn.com/v4/letter/h/e5b9ba/32.png) [@honzatoegel](https://discuss.huggingface.co/u/honzatoegel)\
**Post date:** [August 17, 2023, 1:27pm UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/8 "2023-08-17T13:27:13Z")

</div>

Had issue when i used PEFT+QLoRA and tried to save **Adapter** of the model with:

```auto
model.push_to_hub(...).

```

→ the call actually creates empty repo on huggingface, and ends with above mentioned error `OSError: Tried to clone a repository in a non-empty folder that isn’t a git repository.`  
Then i changed to:

```auto
trainer.model.push_to_hub(...).

```

And it worked, the adapter files was saved to huggingface.

---

<div class="post-metadata">

**Author:** ![maxolotl](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@maxolotl](https://discuss.huggingface.co/u/maxolotl)\
**Post date:** [August 22, 2023, 12:13am UTC](https://discuss.huggingface.co/t/push-to-hub-usage-errors/9132/9 "2023-08-22T00:13:11Z")

</div>

Thanks @honzatoegel, this fix worked for me! The model was saved as a .bin file, however I’m confused by the documentation–is it the model’s state dict that’s stored, or is it something else?
