CLI Companion

  • Hugging Face CLI
    • login
    • whoami
    • repo create
    • upload
    • download
    • lfs-enable-largefiles
    • scan-cache
    • delete-cache
  • Hapi CLI
    • new
    • start
    • build
    • test
    • plugin create
    • route add
  • Cloudflared
    • tunnel
    • tunnel run
    • tunnel list
    • tunnel delete
    • access
    • access tcp
    • update

    The `huggingface-cli repo create` command is used to create new repositories (models, datasets, or Spaces) on the Hugging Face Hub directly from your command line.

    Syntax

    bash
    huggingface-cli repo create [--name REPO_NAME] [--type {model,dataset,space}] [--organization ORGANIZATION] [--private] [--token HF_TOKEN]

    Arguments

    * `--name REPO_NAME`: (Required) The name of the repository to create. If not provided, the CLI will prompt you to enter it.

    * `--type {model,dataset,space}`: (Optional) The type of repository. Can be `model` (default), `dataset`, or `space`. This determines the namespace and default visibility/features on the Hugging Face Hub.

    * `--organization ORGANIZATION`: (Optional) The name of the organization under which to create the repository. If omitted, the repository will be created under your personal user account.

    * `--private`: (Optional) If specified, the repository will be created as private. By default, repositories are public.

    * `--token HF_TOKEN`: (Optional) Your Hugging Face Hub API token. If not provided, the CLI will use the token stored locally after `huggingface-cli login` or prompt you to log in.

    Usage Examples

    1. **Create a new public model repository under your personal account:**

    bash
    huggingface-cli repo create --name my-awesome-model

    This will create `your-username/my-awesome-model` on the Hugging Face Hub.

    2. **Create a new public dataset repository:**

    bash
    huggingface-cli repo create --name my-new-dataset --type dataset

    This creates `your-username/my-new-dataset` as a dataset repository.

    3. **Create a private Space repository:**

    bash
    huggingface-cli repo create --name my-secret-space --type space --private

    This creates a private Space named `your-username/my-secret-space`.

    4. **Create a public model repository under an organization:**

    bash
    huggingface-cli repo create --name team-model-v1 --organization my-org --type model

    This creates `my-org/team-model-v1` on the Hub. You must be an admin of `my-org` to do this.

    5. **Create a repository interactively (without specifying --name):**

    bash
    huggingface-cli repo create --type dataset

    The CLI will then prompt you to enter the repository name:

    > Repo name: my-interactive-dataset

    Explanation

    The `repo create` command streamlines the process of initializing a new repository on the Hugging Face Hub. Instead of navigating the website, you can quickly set up your project's home directly from your terminal.

    * **Repository Types**: Choosing the correct `--type` is important because it dictates the default layout, associated features (e.g., dataset viewer for `dataset` repos, live demo for `space` repos), and how the repository is indexed on the Hub.

    * **Personal vs. Organization**: If you're working in a team, using the `--organization` flag is crucial for collaborative projects, ensuring the repository is managed under the organization's account.

    * **Public vs. Private**: The `--private` flag allows you to keep your work confidential until you're ready to share it. Private repositories are only accessible to you and members of your organization (if created under one).

    * **Authentication**: The command relies on your authentication token. Ensure you've logged in using `huggingface-cli login` or provide a valid token via the `--token` argument. Without proper authentication, you won't be able to create repositories.

    After creation, you can clone the repository to your local machine using Git and push your files. For example, after creating `your-username/my-awesome-model`:

    bash
    git clone https://huggingface.co/your-username/my-awesome-model
    cd my-awesome-model
    echo "My model files go here" > README.md
    git add .
    git commit -m "Initial commit"
    git push