>_ ghcli.com
ghcli / Repositories / gh repo create

gh repo create

Create a repo from your shell

gh repo create makes a new GitHub repository from the command line — empty, from a template, or straight from the local project you're standing in. Push an existing folder up and set the remote in a single command.

Quick answer
gh repo create my-app --public --source=. --push

Syntax

gh repo create [<name>] [flags]

Examples

Interactive create (gh asks the questions)

gh repo create

Create a public repo and push the current folder

gh repo create my-app --public --source=. --push

Create a private repo with a license and .gitignore

gh repo create my-lib --private --license mit --gitignore Node

Create from a template repository

gh repo create my-site --template owner/starter --public

Create under an organization

gh repo create my-org/service --internal

Options & flags

FlagWhat it does
--public / --private / --internalSet the repository's visibility.
-s, --sourcePath to a local repository to push (use . for the current folder).
--pushPush the local commits to the new repository.
-r, --remoteName for the new git remote (default "origin").
-d, --descriptionRepository description.
-p, --templateCreate from a template repository (owner/name).
-g, --gitignoreAdd a .gitignore for the given language.
-l, --licenseAdd a license, e.g. mit, apache-2.0.
--add-readmeInitialize the repository with a README.

How to use gh repo create, step by step

  1. In your project folder run git init and make at least one commit.
  2. Run gh repo create my-app --source=. --public --push.
  3. gh creates the repo, adds it as origin, and pushes your commits.
  4. Open it with gh repo view --web.

Common errors and fixes

Name already exists on this account

Pick a different repository name, or delete/rename the existing one. Names are unique per account or org.

--source or --clone must be used with --push

--push needs local commits to send. Point --source=. at your project, or drop --push for an empty repo.

GraphQL: Resource not accessible by personal access token

Your token lacks repo-creation scope. Re-authenticate with gh auth login and grant the repo scope.

Related commands

Frequently asked questions

How do I create a GitHub repo from the command line?

Run gh repo create. To publish an existing local project in one step, use gh repo create my-app --public --source=. --push, which creates the repo, sets the remote, and pushes your commits.

Can I create a private repository with gh?

Yes. Add --private (or --internal for organizations): gh repo create my-lib --private. Add --license and --gitignore to seed it.

How do I create a repo from a template?

Use --template with the template's owner/name: gh repo create my-site --template owner/starter --public.