DEV Community

Cover image for How to create a Github repository from the command line?
Amrin
Amrin

Posted on • Edited on • Originally published at coderamrin.hashnode.dev

3

How to create a Github repository from the command line?

If you are like me, you don't like to create a GitHub repository on the GitHub website.

That's where the Github CLI comes. Using GitHub CLI we can create a GitHub repository with just a few commands from the command line.

*Before creating a repository using CLI we need to install it. *
You can install Github CLI from this Link.

STEP 1

Using the command line, navigate to the folder you trying to make a repository.
Then using the below command initialize the local directory as a Git repository.

git init -b main
Enter fullscreen mode Exit fullscreen mode

STEP 2

To create a repository on Github we are going to use this command.
Make sure to change the "project-name" with the name you want your repository to be.

gh repo create project-name
Enter fullscreen mode Exit fullscreen mode

STEP 3

Now, Follow the interactive prompts. If you don't like it. you can specify arguments to skip these prompts. For more information about possible arguments, see the GitHub CLI manual.

STEP 4

Pull changes from the new repository that you created.

git pull --set-upstream origin main
Enter fullscreen mode Exit fullscreen mode

STEP 5

Lastly, add files edit files and push them to Github.

git add . && git commit -m "initial commit" && git push
Enter fullscreen mode Exit fullscreen mode

Resources :
https://docs.github.com/en/github/importing-your-projects-to-github/importing-source-code-to-github/adding-an-existing-project-to-github-using-the-command-line

Conclusion

I like this approach of making a Github repo. Cause I get to click less.
If you have any questions please leave a comment. I will be more than happy to talk to you.

And if you like my articles. Follow me on Twitter at @coderamrin

Thanks for READING.
Have a nice day.

AWS Security LIVE! Stream

Stream AWS Security LIVE!

The best security feels invisible. Learn how solutions from AWS and AWS Partners make it a reality on Security LIVE!

Learn More

Oldest comments (0)

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay