Getting Started With Visual Studio Code : Part 2

Introduction

In order to start, you need to have a Git Repository at your local machine. You can have it in multiple ways, some are given below.

Install Git Client on your machine if you haven't already from  git-scm.com/downloads and initialize your project folder with git configuration using the “git init” command.

Figure 1 Initialize Folder with "git init"

Clone a Git Repository from any Git Repository Provider, be it github, BitBucket, GitLab or any other, they are so many out there.

Figure 2 Clone Git Repository

Download the Git Repository as a Zip file and unzip to your local machine.

Figure 3 Download Git Repository as a Zip File

Note: If you're initializing your project folder using “git init”, be sure the destination repository is completely empty when you push/sync all your changes. It won't let you push your changes otherwise and will produce an error.

When you're done with that, the first step is to open the folder in Visual Studio Code.

Figure 4 Select Folder

Figure 5
Empty Git Repository Configuration

You can add a new file or folder or modify any existing file in your project folder and the changes will be highlighted in the leftmost sidebar:

Figure 6 Add/Modify File(s)/Folder(s)

If you look at the left sidebar in the preceding screenshot, it shows 3 changes have been made since the last commit (or inside the freshly opened folder).

Side-by-side editing gives you a great feeling to work along. They are looking fine, but it would be great if you're working with a dual monitor.

Figure 7 Change Count in Left Sidebar

When you click the Git icon, you will see the list of files with changes. Click on any file in the list to see what exact changes have been made to that specific file:

Figure 8 Check your changes

In the list of changes you have a choice to stage or undo a specific change or the entire changes at once:

Figure 9 Undo or Stage individual file changes.


Figure 10 Undo or Stage All the changes at once


There's a Commit Message Box above the list of changes and a few icons right on top of it as in Figure 11.


Figure 11 Message Box

The Tick Mark is used to commit all the staged changes. A commit message is required before you hit the commit tick mark button. The next button in the row is to refresh the list of changes.

The ellipsis allows you to Sync/Pull/Push/Stage/Commit/Clean your changes. So you can push all your changes to your Git Provider right from the Visual Studio Code.

Figure 12 Sync/Pull/Push/Stage/Commit/Clean

This concludes the Git integration in Visual Studio part and now you should be able to utilize all the Git features and commands in Visual Studio code.

I hope you find this reading enjoyable and useful. In the next article of the series we will see how to work with C# projects in Visual Studio and explore its features.