gh repo create: Usage, Options & Common CI Errors
Create a new GitHub repository from the command line.
gh repo create makes a new repository - empty, from a template, or from a local directory - and can set visibility and push your existing code in one step.
What it does
gh repo create <name> creates a repo under your account or an org. With --source it initializes from a local directory and (with --push) pushes it; --template clones a template repo; --public/--private/--internal set visibility. In CI you must pass these flags so it does not prompt.
Common usage
# Create an empty private repo
gh repo create my-org/service --private
# Create from the current directory and push
gh repo create my-org/service --private --source=. --remote=origin --push
# Create from a template
gh repo create my-app --public --template owner/template-repoCommon error in CI: name already exists / missing flags
gh repo create fails with "Name already exists on this account" or hangs prompting for visibility when run non-interactively. Fix: supply visibility (--public/--private/--internal) and the full owner/name explicitly, and choose a unique name (check with gh repo view owner/name first). The token needs repo scope (and org membership/permission for org repos). For org creation, the org must allow the chosen visibility.
Key options
| Option | Purpose |
|---|---|
| --public / --private / --internal | Visibility (required in CI) |
| --source PATH | Initialize from a local directory |
| --push | Push the local commits after creating |
| --template OWNER/REPO | Create from a template repo |
| --remote NAME | Name for the added git remote |