---
source: https://iinventedlight.com/library/notes/hf-hub-upload-files.md
title: "Uploading to the Hub with huggingface_hub"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (huggingface/transformers, huggingface_hub, diffusers docs; LICENSE verified in each repo); prose restates cited source lines in own words"
license_family: hf-apache
attribution: "Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs, Upload files to the Hub, Apache-2.0 (huggingface docs repos); Hugging Face docs, Create and manage a repository, Apache-2.0 (huggingface docs repos)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-09
status: published
checked_on: 2026-11-09
as_of: 2026-11-09
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Hugging Face"
tags: [hugging-face, huggingface-hub, upload, repositories]
client: Librarian
sources:
  - id: S1
    title: "Upload files to the Hub"
    publisher: Hugging Face docs
    url: https://huggingface.co/docs/huggingface_hub/guides/upload
    accessed: 2026-11-09
    license: "Apache-2.0 (huggingface docs repos)"
  - id: S2
    title: "Create and manage a repository"
    publisher: Hugging Face docs
    url: https://huggingface.co/docs/huggingface_hub/guides/repository
    accessed: 2026-11-09
    license: "Apache-2.0 (huggingface docs repos)"
---
# Uploading to the Hub with huggingface_hub

**Answer:** Log in to your Hugging Face account, create a repository with `create_repo`, then upload a file to your repository using `upload_file`.

Use `upload_folder` to upload a local folder to an existing repository. The `hf upload` command uploads files from the terminal.

## Repositories

`create_repo` creates a model repository by default; set the repository type to `dataset` or `space` when needed. A repository can be public or private.

## Folder uploads

- The root `.gitignore` file is taken into account; `.gitignore` files in subdirectories are not checked.
- `allow_patterns` and `ignore_patterns` filter which files to upload; `delete_patterns` deletes remote files in the same commit.
- With `hf_xet` installed (the default), folders with many files are automatically split into several commits to stay below server limits.
- Interrupted uploads are resumable: re-run the same call and files already committed are skipped.

## Low-level commits

`create_commit` takes operations: `CommitOperationAdd` uploads a file, `CommitOperationDelete` removes a file or folder, `CommitOperationCopy` copies a file.

## Artifacts

- [Topic packet: huggingface](https://iinventedlight.com/library/packets/huggingface.json)

## See also

- [hf-hub-download-files](https://iinventedlight.com/library/notes/hf-hub-download-files/)
- [huggingface-hf-cli](https://iinventedlight.com/library/notes/huggingface-hf-cli/)
- [hf-datasets-upload](https://iinventedlight.com/library/notes/hf-datasets-upload/)

## Claims

- id: C1
  claim: upload_folder uploads a local folder to a repo.
  source: S1
  evidence: "function to upload a local folder to an existing repository."

- id: C2
  claim: Interrupted uploads resume by re-running.
  source: S1
  evidence: "if the upload is interrupted for any reason, simply re-run the same call."

- id: C3
  claim: Only the root .gitignore is used.
  source: S1
  evidence: "present at the root of the directory will be used."

- id: C4
  claim: A repository can be public or private.
  source: S2
  evidence: "A repository can be public or private."

## Sources

- [S1] Upload files to the Hub. Hugging Face docs. https://huggingface.co/docs/huggingface_hub/guides/upload . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-09.

- [S2] Create and manage a repository. Hugging Face docs. https://huggingface.co/docs/huggingface_hub/guides/repository . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-09.


License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs (huggingface/transformers, huggingface/huggingface_hub, huggingface/diffusers on GitHub), Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
