Getting Git to work with Visual Studio Code on OS/X takes a bit of finagling If interested, read on.
Install Git
OS/X has Git installed by default so there is no requirement to install Git in order to support integration with Visual Studio Code. To verify Git, from Visual Studio Code's View menu select Terminal:
In the Terminal window, type
git --version and hit return:
The version git in the example above is 2.17.2. If Git is not found or if there is an error in configuration Git with Visual Studio Code, install the latest version of Git.
Azure DevOps Git: Setting up Alternate Credentials
A Git repository hosted in Azure DevOps is accessed via the web using a Microsoft ID (email) and password. Using these credentials with Git commands is an incredible security vulnerability. One workaround is to create alternate credentials for accessing a Git repository hosted in Azure DevOps Creating such credentials is discussed in:
Git: Alternate Credentials in Azure DevOps (a.k.a.
Determine the Repository to be Cloned
Git comes in many flavors Github (owned by Microsoft), BitBucket (owned by Atlassian) and Azure DevOps (owned by Microsoft). Below is an example of a Microsoft Azre DevOps repository (
<vanity name>.visualstudio.com) and note that the Repos tab is selected on the left side:
Most flavors of Git place a clone button on their website. The Clone button is on the upper right above and clicking on it displays the following:
The URL to clone can be copied by clicking on the copy button to the right:
Notice also there is a button, Clone in VS Code.
Cloning via the Clone in VS Code button
Clicking on the Clone in VS Code is a feature that only works in a Microsoft Azure DevOps Repository and of course assuming that Visual Studio Code is the to be used to access Git. When Clone in VS Code is clicked on a dialog such as the following is displayed:
Clicking on the button, Open Visual Studio Code just opens Visual Studio Code. There is no initiation of cloning a Git repository.
Add Username to Git Clone URL
A URL used to clone git takes such as the following:
https://admiralgracehopper@dev.azure.com/admiralgracehopper/Frontend/_git/Frontend
Add the alternative username to the URL:
https://redsox%3APassingPlan@dev.azure.com/PassingPlan/Frontend/_git/Frontend
The %3A in the previous URL is just the HTML escape sequence for the colon character. The style of URL above is what should be used for cloning in Visual Studio Code.
Cloning Directly in Visual Studio Code
Visual Studio Code supports a Command Palette which on OS/X can be opened using ⇧⌘P (holding the shift-command and P characters at the same time). The Command Palette is a textbox that allows command-line style comments to be run against Visual Studio code.
To clone a repository, use ⇧⌘P, to open the Command Pallet and enter the following command followed by hitting the enter key:
Git: Clone
When Git: Clone is entered in the Command Pallet, Visual Studio Code looks as follows:
Select Git: Clone from the drop down and you will receive the following prompt:
In the textbox (as shown above) paste the URL to clone which includes the username associated with the repository:
Pressing Enter (as instructed above) display the folder selection dialog so that the folder into which the directory clone is to be placed: