How to use Git and GitHub inside of VS Code Editor
Tags: git, github, codenewbie, vscode
Published: 2020-11-30 08:01:14

Hello Everyone,<br>
In today's tutorial, I am going to show you How to use Git and GitHub inside of VS Code Editor.<br>
After reading this blog, you don't need to remember all those git commands.<br>
If you prefer to watch a video tutorial, you can check it out over  [here](https://youtu.be/fsMtyJZ3A_Q).
## Basic Setup
First, start by creating a new folder and name it whatever you want, and then open it with VS Code Editor.
![Screenshot from 2020-11-28 15-54-37.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606559110472/0RwhVHdCf.png)
And then create a new file inside this folder like a index.html file or name it whatever you want so that we can make some changes to it and demonstrates to you how git and GitHub work inside the VS Code Editor.<br>
Now add a simple boilerplate inside the index.html file by pressing shift + 1.
![Screenshot from 2020-11-28 16-02-05.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606559557320/BvniHxb-R.png)

> Please make sure you are using the latest version of VS Code Editor(I'm using the version: 1.51.1)

## Create a GitHub repository
Let's create a new GitHub repository right inside of VS Code Editor. Now, you don't need to go to the official GitHub site and then create a new repository from there anymore.<br>
First, click on the source control icon on the left sidebar or press 
`ctrl + shift + g` to open source control panel. It should look like this.
![Screenshot from 2020-11-28 16-57-14.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606562883875/ts4Cay7B1.png)
And then click on the `Publish to GitHub` button.
This will open a dialog box like this.
![Screenshot from 2020-11-28 16-58-42.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606563728595/HG-RGeCLe.png)
and then click on the `allow` button, this will allow the GitHub extension to sign in using your GitHub account.<br>
After that, a window will open in your browser to authorize your GitHub account, just click on the `Continue` button and then click on the `Authorize` button to authorize your GitHub account.
Now your GitHub account is setup inside of VS Code Editor.
Again open the VS Code, you will see a dialog box like this.
![Screenshot from 2020-11-28 17-09-53.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606564362548/Wb3V3BlhF.png)
First, enter your project name or leave it to default and then select the repository type. If you want to create a public repository, click on the `Publish to GitHub public repository`, else click on the `Publish to Github private repository`.<br>
Now, your Github repository is created, if you want to check it, go to the repository section of your GitHub account.
Now, your source control tab should look like this.

![Screenshot from 2020-11-28 17-36-27.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606565341511/ODVhLdtjo.png)

## How to use Git inside of VS Code Editor?
Now, make some changes in the index.html file so that we can learn How to use Git inside of VS Code?
I just added an h1 tag inside the file, now the source control panel shows that changed file under the `Changes` section.
![Screenshot from 2020-11-28 17-50-22.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606566061851/xIN0h_uGv.png)
The next step is to stage these changes, just click on the plus button to stage the changes and if you want to stage all the changes at once then click on the plus icon that is in line with the `Changes` title respectively.
![Screenshot from 2020-11-28 17-53-10.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606566265801/XF613uvkx.png)
![Screenshot from 2020-11-28 17-56-05.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606566500631/KfFwEozpd.png)
All the changes are now staged. The next step is to commit these changes.
Enter your commit message inside the input and then click on the tick icon to commit all the changes like this.
![Screenshot from 2020-11-28 18-01-39.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606566826481/rj7ZWWxXO.png)
Now, the next step is to push these changes to your GitHub repository.
Click on the three-dot button and then click on the Push, Pull option, and then click on Push. This will push all the changes to the master branch.
You can also create a new branch, click on three dots, and then click on Branch and then click on Create Branch and enter your branch name, this will create a new branch for you. Then push all these changes in the branch.
Now, you pushed the changes, if you want to check it, open this repository in your browser.
![Screenshot from 2020-11-28 18-17-08.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606567912659/KrKA27IAI.png)
![Screenshot from 2020-11-28 18-28-29.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606568338747/XTqQp6fhX.png)

Congratulations🎉! You successfully pushed your changes to your GitHub repository without opening the command line.<br>
Hopefully, you learned about How to use Git and GitHub inside of VS Code Editor.

# Thanks for reading this blog

If you find the blog helpful, feel free to subscribe to our newsletter so whenever our new post goes live, you'll get the notification first.
 
Do leave your feedback and suggestions as comments.

[Check out my youtube channel](https://bit.ly/2F1aZIh)

[Let's connect on Twitter](https://twitter.com/thefierycoder)

Thank You