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 on the Hugging Face Hub directly from your command line. These repositories can be of various types: models, datasets, or Spaces.

    Syntax

    bash
    huggingface-cli repo create <repo_id> [--type {model,dataset,space}] [--organization <org_id>] [--private]

    Arguments

    * `<repo_id>`: (Required) The unique identifier for your new repository. For personal repositories, this will be in the format `<your-username>/<repo-name>`. If you are creating it under an organization, it will be `<org-name>/<repo-name>`. If only `<repo-name>` is provided, it defaults to a personal repository under your logged-in user.

    * `--type {model,dataset,space}`: (Optional) Specifies the type of repository. If not provided, it defaults to `model`.

    * `model`: For machine learning models.

    * `dataset`: For datasets.

    * `space`: For Hugging Face Spaces (demos, web apps).

    * `--organization <org_id>`: (Optional) Specifies the organization ID under which the repository should be created. You must be a member of the organization with sufficient permissions.

    * `--private`: (Optional) Makes the repository private. By default, repositories are public. Only you (or members of your organization) will be able to see and access private repositories.

    Usage Examples

    1. **Create a public model repository (personal):**

    bash
    huggingface-cli repo create my-awesome-model

    *Explanation:* This creates a new public model repository named `my-awesome-model` under your personal user account. The full `repo_id` will be `your-username/my-awesome-model`.

    2. **Create a private dataset repository (personal):**

    bash
    huggingface-cli repo create my-secret-data --type dataset --private

    *Explanation:* This creates a new private dataset repository named `my-secret-data` under your personal user account.

    3. **Create a public Space repository for an organization:**

    bash
    huggingface-cli repo create my-org/my-demo-space --type space --organization my-org

    *Explanation:* This creates a new public Space repository named `my-demo-space` under the organization `my-org`. You must have the necessary permissions within `my-org`.

    4. **Create a public model repository specifying full repo_id:**

    bash
    huggingface-cli repo create your-username/my-new-model --type model

    *Explanation:* This explicitly creates a model repository `my-new-model` under `your-username`. This is equivalent to the first example if `your-username` is the currently logged-in user.

    Explanation

    Before using `huggingface-cli repo create`, you need to be logged in to the Hugging Face Hub from your terminal. You can do this using `huggingface-cli login`.

    This command simplifies the process of initializing repositories on the Hub. Once a repository is created, you can then clone it, add your files (models, datasets, application code), and push them to the Hub using standard Git commands.

    For example, after creating `my-awesome-model`:

    bash
    huggingface-cli repo create my-awesome-model
    git clone https://huggingface.co/your-username/my-awesome-model
    cd my-awesome-model
    # Add your model files here, e.g., model.safetensors, config.json
    git add .
    git commit -m "Initial commit of my awesome model"
    git push

    This command helps streamline the workflow for machine learning practitioners and developers by integrating repository management directly into their command-line environment.