hf copy_files and hf buckets cp copy between repositories
Introduced 2026-05-28 · score 0.97
HOW TO USE IT
When copying files or folders between Hub repositories, use `copy_files` with `hf://` source and destination URIs; use `hf buckets cp` for CLI repo-to-repo file copies. For direct `CommitOperationCopy` cross-repository sources, set `src_repo_id` and `src_repo_type` (required when `src_repo_id` is set).
from huggingface_hub import copy_files
copy_files(
"hf://datasets/<owner>/<source-repo>/data/",
"hf://datasets/<owner>/<target-repo>/data/",
)hf buckets cp hf://<owner>/<source-repo>/config.json hf://<owner>/<target-repo>/config.jsonCommitOperationCopy(src_path_in_repo="<source-path>", path_in_repo="<destination-path>", src_repo_id="<owner>/<source-repo>", src_repo_type="<model|dataset|space>")WHY THIS HELPS
Copy files or a folder between Hub repositories without downloading and re-uploading the data.
REQUIREMENTS AND LIMITATIONS
- Version: v1.17.0
- source URI / `src_path_in_repo` (required): Source file or folder URI for `copy_files`; source repository path for `CommitOperationCopy`.
- destination URI / `path_in_repo` (required): Destination URI for `copy_files`; destination repository path for `CommitOperationCopy`.
- `src_repo_id`: Source repository ID; defaults to the destination repository. If set, `src_repo_type` is required.
- `src_repo_type`: Source repository type: `model`, `dataset`, or `space`; required when `src_repo_id` is set.
- `src_revision`: Revision to copy the source file from.
- CLI `SRC` and `DST` (required): The source and destination locations; each can be a local path, `hf://` URI, or `-` for stdin/stdout.
- Prerequisite: For Hub uploads, the docs say to log in to a Hugging Face account.
- Supports model-to-model, model-to-dataset, and other repository combinations.
- LFS blobs are deduplicated server-side; non-LFS files are fetched from the source repository and committed as regular payloads.
FIRST-PARTY EVIDENCE
- https://github.com/huggingface/huggingface_hub/releases/tag/v1.17.0
- https://huggingface.co/docs/huggingface_hub/v1.20.1/en/guides/upload
- https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/guides/cli.md?plain=1
- https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/guides/upload.md
Check the installed version and the source before using it. Entry JSON