In this article I want to give an overview about the integration of Visual Studio Code and Git with Azure DevOps on my Windows 10 machine.
Azure DevOps – formerly VSTS – is the version of Team Foundation Server hosted on Microsoft Azure. Azure DevOps includes Azure Pipelines, Azure Boards, Azure Artifacts, Azure Repos and Azure Test Plans.
In order to gain first experiences with Azure RM Scripting, automated deployment and code repositories I took a look at Visual Studio Code (VSCode). This is a free source code editor from Microsoft. With Azure Repos you get free private Git repositories and will be able to do code collaboration in the cloud.
Setup Visual Studio Code & Git
The next step is to download the latest version of Git from https://git-scm.com/download . Choose all the defaults except change VS Code to the default editor. That’s actually optional but I did it.
If you haven’t created an Azure DevOps project yet, you should do so now. You have as well a new created repository. Navigate in your browser to Azure Repos.
I have created a folder to synchronize the repository to the local harddisk.
In the File-Explorer there is now the option “Git Bash Here” with right click available. The following window appears in which you initialize Git with the command “git init”.
This command creates a subdirectory .git, which contains all relevant Git Repository data, i.e. a Git Repository framework.
Clone Git Repository
The next step is to clone the git repository from Azure DevOps to the local disk.
git clone "https://ORGNAME@dev.azure.com/ORGNAME/DevOpsProjectName/_git/This%20is%20my%20REPO" "c:\_repos_\ThisIsMyRepo"
Update: this Bug has been resolved!
Note: In Azure DevOps there is a button that you can press to synchronize. It doesn’t work if the URL contains spaces because of a bug. For this reason I executed the clone command via the Git Bash. Therefore replace the “blanks” with %20 and it will work.
The next command is only needed if the repository is completely empty. It will create a complete new history of the project. If you do not execute this command, Git will not work in VSCode.
git pull --allow-unrelated-histories
If you are now starting Visual Studio Code you need to click “Add Workspace folder…” on the Welcome Screen and choose the Git Folder on your harddrive. This will look like this. As you can see, I have already created a folder and a new PowerShell file.
Signin to Azure DevOps-Team
to collaborate now with your colleagues in Azure DevOps you need to sign-in first. For doing this click on “View” in the navigation pane and choose “Command Palette” or press “CTRL+SHIFT+P”. In the command window enter “Team: Signin” and choose your authentication method. I prefer the “new experience”.
I already described this new authentication method in the post about the PowerShell Az module.
Now you are ready to start your code-collaboration with Visual Studio Code, Azure DevOps and Git repos. Feel free to give feedback on this post and add comments.