Visual Studio Code and Visual Studio Online

Visual Studio Code has lots of different advantages like:

  • It’s very fast and doesn’t require much resources. Even on my Windows laptop, where I have Visual Studio Enterprise installed, I like to use Visual Studio Code to open JavaScript or TypeScript files just to check something using formatting features. It’s as fast as opening a text file in Notepad but I have fully featured IDE;
  • It supports more than 30 programming languages. So, I can easy use it together with Unity 3D to edit C# and JavaScript files or I can edit HTML markup and TypeScript files;
  • It supports different operation systems like Linux and MacOS. Therefore, you can continue to use Visual Studio Code running Unity3D projects on Mac or when you create web sites or server-side components using Node.js;

But today I am going to talk about another important advantage, which is integration with Git. Since even I am the only person in the team I will use version control system in any case. Of course, Git is just a platform and it requires a provider, if you are not going to setup your own infrastructure. And if you are planning to create an open source project which will be uploaded to a public repository, probably, you will use GitHub as a provider. GitHub allows you to create an unlimited number of public repositories for free. But once you want to create a private repository or want to have access to number of tools which help you to support Software Development Life Cycle, it’s better to use Visual Studio Online.

Visual Studio Online allows you to have up to 5 developers per your account for free and you can create any number of projects there and use some additional features like Sprint planning tools, Task and Kanban boards, virtual team room etc. And, of course, Visual Studio Online supports Git and thanks to that you can use Visual Studio Code and Visual Studio Online together.

If you still don’t have an account for Visual Studio Online, it’s time to get one for free.

Once you get access to Visual Studio Online you can create a project. In this case project means everything that is related to application lifecycle management: dashboards, repository, team room etc. Pay special attention that Visual Studio Online supports two types of version control including Git. Because we are going to use Visual Studio Code we need to select Git:

Once the project is created you need to do one more thing inside Visual Studio Online – open your profile and use Security tab to apply Alternate authentication credentials. By default Visual Studio Online uses LiveID to make authentication but Git tools don’t support LiveID. So, without this step you will not be able to setup Git on your PC.

One more step on the server side is getting URL that you can use as a remote repository in Git. Just navigate to the project and open CODE tab. You will see the URL – just copy it for next step.

That’s all done on server side.

I assume that you already installed Git on your PC and know how to run the command line. First of all you need to provide Git your user name which you defined in Visual Studio Online as an alternate credential:

git config --global user.name sbaidachni

If you still have not created a local repository, you can do it by using the following commands:

git init

This command will make the current folder a local git repository.

Finally, you can add the reference to our remote repository:

git remote add origin https://canadaapps.visualstudio.com/DefaultCollection/_git/VSCodeProject

That’s all. Just open the local folder using Visual Studio Code and you should see that most of menu items of Git tab are already enabled for you:

You can start coding and commit all changes to Visual Studio Online.