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.
I already have an article and a video talking about how to use VSCode with GitHub, but, as someone has pointed out:
That content assumed you already had your code on GitHub. But what if you don’t? Let’s do it now.
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:
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
And this will prompt you to either Initialize Repository or Publish to GitHub
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.
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).
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.
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:
☕ Buy me a coffee
🌐 CoderDave.io Website
👦🏻 Facebook page