CN

Danilo Mello

Frontend Engineer

Go Back

Creating a new repository on Github via Terminal

Hey folks!

Today I wanna share with you how I quickly create new repositories on GitHub just using my Terminal.

If you didn't knew Github has a CLI, that enable you to create and manipulate your repositories. Which make your life easier when you are creating new repository for your projects, prototypes and POCs. Install here

Once you install the CLI follow the steps below to create a new repository.

First, initialize Git:

git init

Second, create a new branch called main:

git checkout -b main

Now create a new repository using the gh**** command.

gh repo create repo-name --public --source=. --remote=origin
  • A flag --public make the repository public
  • A flag --source define the path/folder for the repository
  • A flag --remote define origin name for the repository

Once you create the repository, add all files to staged:

git add .

Now create your first commit:

git commit -m "feat: add initial react files"

And push all your updates to the main branch:

git push -u origin main

Now to see if it worked it properly, try to access the repository:

gh browse

Great! You did it! You just create a resposity via terminal.