Skip to content
Latchkey

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

Terminal
# 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-repo

Common 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

OptionPurpose
--public / --private / --internalVisibility (required in CI)
--source PATHInitialize from a local directory
--pushPush the local commits after creating
--template OWNER/REPOCreate from a template repo
--remote NAMEName for the added git remote

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →