DEV Community

Cover image for Create a New GitHub Repo in 1 CLICK from VSCode
Davide 'CoderDave' Benvegnù
Davide 'CoderDave' Benvegnù

Posted on

Create a New GitHub Repo in 1 CLICK from VSCode

Do you have some code in VSCode and want to take it to GitHub, without having to write a single command in the CLI? Today I’m gonna show you how to do that, how to publish your code to a new GitHub repo, all from VSCode.

Introduction

I already have an article and a video talking about how to use VSCode with GitHub, but, as someone has pointed out:

Comment from YouTube

That content assumed you already had your code on GitHub. But what if you don’t? Let’s do it now.

Video

As usual, if you are a visual learner, or simply prefer to watch and listen instead of reading, here you have the video with the whole explanation and demo, which to be fair is much more complete than this post.

Link to the video: https://youtu.be/shP-3p-2m6g

If you rather prefer reading, well... let's just continue :)

Just one prerequisite

Everything you need to create a new repository in GitHub from VSCode is already present in Visual Studio Code itself. The only thing you need to make sure to do before hand is logging in into VSCode with your GitHub user.

Your VSCode should look like this:

VSCode Login

Of course with your username, not mine 😇

If it is not like this, click on Sign In (GitHub) and you are good to go.

Create the repo

Now that we know we are logged in, creating the repository in GitHub is very easy.

Just click on the Git - Source Control icon

SCM VSCode

And this will prompt you to either Initialize Repository or Publish to GitHub

New Repo Choice

The first option does only execute the git init command, so it does technically create a repository for you but only on the local machine. If you want to have your repo in GitHub, instead, use Publish to GitHub. This will do for you the repo initialization as well, but will also create a new repo in GitHub and push the code to it.

Repo Type Selection

When you click on Publish to GitHub, VSCode will ask you what name you want your new repo to have (defaults to the name of the root folder of your project) and you can choose whether you want your new repo to be private or public.

Last thing you can do is select what files or folders you want to include in your repo (the default is everything, so if that's what you want to do you can just skip this step).

Repo File Selection

And after that, VSCode will do its magic, create the repo for you in GitHub, set it as the origin on the local folder, and push the code.

Completed

Conclusions

Cool right? And you know what would be even cooler? If you could hit the like buttons on the side :)

Jokes aside, now that your code is on GitHub, go and check this other video I’ve mentioned before to see how you can manage it directly from VSCode as well.

Like, share and follow me 🚀 for more content:

📽 YouTube
Buy me a coffee
💖 Patreon
📧 Newsletter
🌐 CoderDave.io Website
👕 Merch
👦🏻 Facebook page
🐱‍💻 GitHub
👲🏻 Twitter
👴🏻 LinkedIn
🔉 Podcast

Buy Me A Coffee

Top comments (4)

Collapse
 
manuripo profile image
Manuela Ripollés Orovitg

How do you add a second one? I have created one github repository and i want to create another one from a different folder, but the initialize repository/publish in github window doesn´t appear. only the source control repository that i have just created. Thanks

Collapse
 
n3wt0n profile image
Davide 'CoderDave' Benvegnù

If the folder is outside of the other repo, it should let you do it.

Try opening vscode from that folder

Collapse
 
colin-williams-dev profile image
colin-williams-dev

so simple, but never knew this. thank you.

Collapse
 
n3wt0n profile image
Davide 'CoderDave' Benvegnù

You're welcome :)