In this blog post, we will see how easy it is to create a new repository in GitHub directly from the command-line using GitHub CLI without accessing the website.
If you are new to GitHub CLI, visit the following post on how to set it up on your machine.
The GitHub Command Line Interface (CLI) is a useful tool that connects to GitHub and allows you to create, edit and delete repos as well as run workflows with ease. The Node. js-based GitHub CLI is intended to be extended and customized for your needs.
Create a Repository
To create a new repository, I will first create a directory with the name of the repository.
After creating the repository, I will access it.
Using the command below, I’m initializing the repository.
Now starts the fun part of GitHub CLI, using the command below, I’m creating a new repo.
gh repo create
After issuing the command, the CLI will ask me a few questions, the important one is the visibility type so make sure it is set to private.
After adding a new file to the repo, I will use the commands below to add, commit and push the changes to the repository in GitHub.
git add .
git commit -m "First commit"
git push -u origin main