Command referencegh repo create
gh repo create command (Linux & Windows / GitHub CLI)
What it does
Create a new GitHub repository from the current directory or as an empty remote repo. When people search for gh repo create, they usually want practical GitHub CLI flags, safe examples, and how this subcommand fits everyday PR and repo workflows on Linux, Windows, and macOS. Syntax, options, and copyable examples are below.
Create a new GitHub repository from the current directory or as an empty remote repo.
Syntax
gh repo create [<name>] [flags]
Common options
| Flag / option | Meaning |
|---|---|
| --public | Make the repository public. |
| --private | Make the repository private. |
| --source | Local path to use as the repository source. |
| --remote | Local remote name to add (often origin). |
| --push | Push local commits after creating the remote. |
| --description | Short repository description. |
Practical examples
Create from cwd
gh repo create my-app --private --source=. --remote=origin --push
Creates a private GitHub repo and pushes the current project.
Empty public repo
gh repo create demo --public
Creates an empty public repository under your account.
With description
gh repo create notes --public --description "Scratchpad"
Sets the GitHub description at creation time.
Common mistakes
- Creating a public repo when the project still contains secrets.
- Omitting `--source` when you meant to publish the current folder.
Related commands
- gh repo cloneClone a GitHub repository to your machine using your authenticated gh settings.
- gh repo viewDisplay metadata about a GitHub repository in the terminal or open it in a browser.
- gh repo deleteDelete a GitHub repository permanently after confirmation.
- gh auth loginAuthenticate the GitHub CLI with GitHub.com or GitHub Enterprise so other gh commands can run.
- gh pr createCreate a pull request from the current branch with title, body, reviewers, and base branch options.
- gh pr mergeMerge a pull request using merge commit, squash, or rebase strategies.
- gitTrack source history and collaborate through distributed repositories.
- gh pr checkoutCheck out a pull request locally as a branch so you can build, test, or review the changes.
FAQ
What does gh repo create do in GitHub CLI?
Create a new GitHub repository from the current directory or as an empty remote repo.
Does gh repo create work on Windows and Linux?
Yes. The GitHub CLI (`gh`) runs on Linux, Windows, and macOS with the same subcommand syntax after you authenticate with `gh auth login`.
What is a practical gh repo create example?
Try `gh repo create my-app --private --source=. --remote=origin --push` — Creates a private GitHub repo and pushes the current project.
Do I need a token in the command line for gh repo create?
Prefer `gh auth login` so credentials stay in the system keyring or secure storage. Avoid pasting personal access tokens into shell history.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.