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
.gitignorefile is taken into account;.gitignorefiles in subdirectories are not checked. allow_patternsandignore_patternsfilter which files to upload;delete_patternsdeletes remote files in the same commit.- With
hf_xetinstalled (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
See also
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.
License: CC-BY-4.0 · 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).
Cite this
iinventedlight. 2026. "Uploading to the Hub with huggingface_hub." iinventedlight Library, iil:note:0ng30ymp, version of 2026-11-09. https://iinventedlight.com/library/notes/hf-hub-upload-files/. License: CC-BY-4.0.
@misc{iil_note_0ng30ymp,
author = {{iinventedlight}},
title = {{Uploading to the Hub with huggingface\_hub}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-09},
url = {https://iinventedlight.com/library/notes/hf-hub-upload-files/},
note = {Permanent ID iil:note:0ng30ymp. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/hf-hub-upload-files.md.