DEV Community

Cover image for Create a new github repo from the command line
Alaa Atwa
Alaa Atwa

Posted on

Create a new github repo from the command line

Hi friends,
let's say you want to create a new Repo in your terminal and push it to your Github, here is the steps to do that:

1.convert your directory to a git repo with the command :

git init
Enter fullscreen mode Exit fullscreen mode

2.stage your files, so you can commit them

git add .
Enter fullscreen mode Exit fullscreen mode

or optionally you can select a file name by:

git add file_name/s
Enter fullscreen mode Exit fullscreen mode

3.you need to authorize your github cli if you haven't already , I use ** gh ** for that, you can download it first if you don't have it (sudo apt install gh) in Debian Distros

gh auth login
Enter fullscreen mode Exit fullscreen mode

just follow the instruction to complete the authentication steps

4.finally :) , create the new repo
using ** gh ** again with options ** gh repo create**

gh repo create newrepo_name --public --source=. --remote=upstream --push 
Enter fullscreen mode Exit fullscreen mode

newrepo_name == the repo name you want to be on github
--public == make the new repo public, you can use "--private"
--source == path to local repo to use as source
--push == Push local commits to the new repository

I hope you enjoyed this tutorial :)
Thanks !

Top comments (0)