LinuxCommandLibrary

hub-clone

Clone GitHub repositories using the hub command

TLDR

Clone an existing repository to current directory (If run into authentication problem, try full SSH path)

$ hub clone [remote_repository_location]
copy

SYNOPSIS

hub clone [-p] [-q] [--recursive] [-b BRANCH] [-c COMMIT] [-L ,] [-l] [--] [USER/][REPO] [DIR]

PARAMETERS

-p
    Do not pipe git output into a pager

-q, --quiet
    Clone repository silently

--recursive
    Initialize submodules recursively (passes to git clone)

-b BRANCH, --branch BRANCH
    Branch/tag to checkout after clone

-c COMMIT
    Commit/tag to checkout after clone

-L START,END
    Line-range to checkout (passes to git clone)

-l, --local
    Use local clone optimization

--
    Stop option parsing; pass remaining args to git clone

DESCRIPTION

hub clone is part of the hub command-line tool, a wrapper around git that adds GitHub-specific features. It simplifies cloning repositories by allowing shorthand names like owner/repo instead of full URLs. Hub automatically resolves the repo on github.com, fetches the clone URL, and configures the remote named origin. This works for public and private repos (with authentication via token or SSH).

It forwards most options to git clone, enabling advanced cloning like specific branches, commits, line ranges, or submodules. Multiple repos can be cloned sequentially. Hub requires installation (e.g., brew install hub, apt install hub) and configuration via hub config or environment variables like HUB_TOKEN.

Ideal for GitHub-heavy workflows, it saves time and reduces errors. Note: supports GHE_HOST for GitHub Enterprise.

CAVEATS

Hub is deprecated and no longer maintained (archived 2021); use gh repo clone from GitHub CLI instead. Requires hub installed and GitHub auth for private repos.

EXAMPLES

hub clone torvalds/linux clones to linux dir.
hub clone -b main -q user/repo ./my-repo quiet clone to custom dir.
hub clone --recursive owner/repo with submodules.

AUTHENTICATION

Set GITHUB_TOKEN env var or run hub auth login for private repos. Supports SSH via ~/.ssh/config.

HISTORY

Developed in 2011 by Chris Wanstrath (@defunkt) and contributors as a GitHub-integrated Git wrapper. Popular in CLI workflows until 2021, when GitHub archived it in favor of the official gh CLI.

SEE ALSO

git-clone(1), hub(1), gh(1)

Copied to clipboard