In this post, I will discuss how to configure Git with Visual Studio code. We recently started working on an AngularJS application and decided to use Visual Studio Code Editor for development.
As a first step, we needed the Visual Studio Code (VSC) to be configured with Team Foundation Server (TFS). VSC has inbuilt capability to be configured with any Git repository (DVCS). Here, I would like to mention that VSC does not have the capability to be integrated with TFS repository (CVCS).
After searching the net, I still could not make out what is the easiest & straightforward way to configure Git in VSC where the Remote Git Repository is already available because I did not find any UI Clone command under Git menu. Also, there is no way to define the remote repository location which needs to be cloned.
Git Context Menu
After playing with VSC for some time, I found the way to configure VSC with Git in just 5 steps which were easy and straight forward.
Before starting to follow the below 5 steps, please make sure that Git is installed on your system. If not, please download & install Git for Windows from https://git-scm.com/downloads.
Let’s see what those 5 steps are:
Step 1: Install .NET Framework 4.5 from Web Installer or Offline Installer.
Step 2a: Open Visual Studio Code
Step 2b: Go to View > Integrated Terminal
Step 2c: Navigate to the directory (Use DOS CD command) where the remote Git repository needs to be cloned. Let's say we would like to clone under C:/Git/ and suppose the remote repository name is
Step 3: Before running the
Clone command, we would be running the following command to cache the Git Credentials in Windows, else whenever Git Sync/Pull/Push command is triggered, it will ask for credentials. This step can be avoided, if you are OK to provide the password every time.
Cache Credentials to avoid prompt every time.
Step 4: Now type git clone <Your Remote Git Repository URL> as shown in the below picture. Press Enter.
Step 5: Credentials window should be opened. This would ask the credentials which would allow you to connect with remote repository.
Git Credentials Window
Once the credentials are provided, VSC will start cloning the Remote Repository under navigated folder.
Make sure the git command is typed in small characters, or else you may get “fatal: cannot handle Clone.exe as a builtin“.
Clone Remote Git Repository using Integrated Terminal
In order to use the local repository, Please Go to File > Open Folder and select the folder from C:\Git\<Git Repository Folder> or your own folder. This will open all the files in explorer and you can start changing the files.
Tagged: AngularJS, DVCS, Git, Git Configuration, Visual Studio Code, VSC