Adding your project in source control (GitHub and VS Code)
Tags: programming, github
Published: 2020-01-20 12:50:53

---
title: Adding your project in source control (GitHub and VS Code)
published: true
date: 2019-12-29 13:43:26 UTC
tags: programming,github
canonical_url: https://siderite.dev/blog/add-project-to-source-control-github-vscode/
---

Original post at [https://siderite.dev/blog/add-project-to-source-control-github-vscode](https://siderite.dev/blog/add-project-to-source-control-github-vscode)

This is a side post to [Programming a simple game in pure HTML and Javascript](https://siderite.dev/blog/programming-simple-game-in-pure-html-javascript/ "How to create a simple game with HTML and Javascript") in the sense that we are going to add that project to source control in GitHub using Visual Studio Code.

The first step is to create a repository. You need to create a [GitHub](https://github.com/ "Free non private source control") account first, then either go to Your Repositories

![YourRepos.jpg](https://siderite.dev/Posts/files/YourRepos_637132238064974828.jpg)

or click the green New button on the top of your repositories list in the main page.

Make sure you give the repository a name and a decent description. I recommend adding a README and a licence (I use MIT), too.

![CreateRepo.jpg](https://siderite.dev/Posts/files/CreateRepo_637132238065146676.jpg)

Now that you have a **remote** repo on GitHub, you need to remember its URL, you will need it later.

Then download Git from [their website](https://git-scm.com/ " a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency."). The Windows installer is simple to find, download and Next-next-next to success.

Open Visual Studio Code in your project's folder. On the left side menu there are a bunch of vertical buttons, click on the Source Control one  ![SourceControl.jpg](https://siderite.dev/Posts/files/SourceControl_637132238065264106.jpg)

Then initialize your **local** repository by clicking on the plus sign and selecting your project folder:  ![InitRepoFromVs.jpg](https://siderite.dev/Posts/files/InitRepoFromVs_637132238065325772.jpg)

Now you need to connect your local repo to your remote repo and you do this by typing some stuff in the Visual Studio Code Terminal window:

1. set the remote by typing _git remote add origin \<your GitHub repo URL\>_
2. verify the remote by typing _git remote -v_
3. run a git pull to make sure your project loads the readme and license file by typing _git pull origin master_

_![VsRemoteInit.jpg](https://siderite.dev/Posts/files/VsRemoteInit_637132238065397395.jpg)_

Last step is to push your local files to the remote repository. You do this by

1. clicking on the check mark at the top of the Source Control window and giving a description to this first commit  
 ![VSSourceControl.jpg](https://siderite.dev/Posts/files/VSSourceControl_637132238065439331.jpg)  
 ![CommitFromVS.jpg](https://siderite.dev/Posts/files/CommitFromVS_637132238065469793.jpg)
2. pushing/publishing the commit, by clicking on the ... mark and choosing Publish Branch  
 ![VsPublishRepo.jpg](https://siderite.dev/Posts/files/VsPublishRepo_637132238065499971.jpg)

There you have it. Your project is on source control.

You do this in order to not lose your changes, in order to track your changes forwards and backwards in time and to publish your work for others to see it (like other devs or potential employers)

Verify that all went well by refreshing your GitHub project page. The files in your local folder should now be visible in the file list on the page.

Now, every time you make changes to your code you push the changes on GitHub by committing (the check mark) and then pushing/syncing/publishing (from the ... menu)