After a long time, today I got a chance to share my new learning with you all in which 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 capability to be integrated with TFS repository (CVCS).
After searching the net, I still could not make out what is the easiest & straight forward 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 need to be cloned.
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.
Let’s see what are those 5 steps.
Step 2.a: Open Visual Studio Code
Step 2.b: Go to View > Integrated Terminal
Step 2.c: Navigate to the directory (Use DOS CD command) where the remote Git repository need to be cloned. Lets say we would like to clone under C:/Git/ and suppose the remote repository name is sg_angular.
Step 3: Before running the Clone command, we would be running the following command to Cache the Git Credentials in Windows else when ever 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.
Step 4: Now type git clone <Your Remote Git Repository URL> like 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.
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 else you may get “fatal: cannot handle Clone.exe as a builtin“.
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.