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.
gh repo create my-app --public --source=. --pushSyntax
gh repo create [<name>] [flags]Examples
Interactive create (gh asks the questions)
gh repo createCreate a public repo and push the current folder
gh repo create my-app --public --source=. --pushCreate a private repo with a license and .gitignore
gh repo create my-lib --private --license mit --gitignore NodeCreate from a template repository
gh repo create my-site --template owner/starter --publicCreate under an organization
gh repo create my-org/service --internalOptions & flags
| Flag | What it does |
|---|---|
| --public / --private / --internal | Set the repository's visibility. |
| -s, --source | Path to a local repository to push (use . for the current folder). |
| --push | Push the local commits to the new repository. |
| -r, --remote | Name for the new git remote (default "origin"). |
| -d, --description | Repository description. |
| -p, --template | Create from a template repository (owner/name). |
| -g, --gitignore | Add a .gitignore for the given language. |
| -l, --license | Add a license, e.g. mit, apache-2.0. |
| --add-readme | Initialize the repository with a README. |
How to use gh repo create, step by step
- In your project folder run
git initand make at least one commit. - Run
gh repo create my-app --source=. --public --push. - gh creates the repo, adds it as
origin, and pushes your commits. - 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.