Create a new repository with GitHub CLI
- Use the
gh repo createcommand to create a repository for your project directly from the command line. - When prompted, choose “Push an existing local repository to GitHub” and enter your preferred repository name.
- If you want the project to be created under an organization rather than your personal account, specify it as:
gh repo create ORGANIZATION-NAME/PROJECT-NAME
- Follow the interactive prompts
- The CLI will guide you through setup options.
- When asked whether to add the remote and push commits to your current branch, select Yes to complete the setup.
- Skip prompts with command flags (optional)
- To automate the process, include flags directly in your command:
gh repo create --source=. --public --remote=origin --push - Here’s what each flag does:
--source=.→ Uses your current directory as the repository source.--public,--private, or--internal→ Sets repository visibility.--remote→ Specifies the remote name (commonlyorigin).--push→ Pushes all existing commits to GitHub automatically.
- To automate the process, include flags directly in your command:
- Learn more
- See the official GitHub CLI Manual for additional flags, examples, and usage tips.