Version Controlling with Git

1 hour
  • 4 Learning Objectives

About this Hands-on Lab

The days of one developer completing an app from start to finish are long gone. These days, collaboration is important, and you have been tasked with implementing a method to allow efficient collaboration. In the past, developers have made changes that conflict with another developer’s changes, and we want a solution that will allow all of the developers to see the actual changes before they make their own change. Version controlling with Git allows developers to put comments related to the changes in the commit section. Additionally, developers are able to compare versions and see exactly what has changed in the previous version of the code. This is an important feature because it makes collaboration more effective and efficient. We will be utilizing the Azuze DevOps portal and Visual Studio Code to accomplish the solution. At the end of this hands-on lab, you will have a basic understanding of Visual Studio Code and the integrated version control for Git within Azure Repos.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Cloning an Existing Repository
  1. Open Visual Studio Code.
  2. From the main menu, select Terminal > New Terminal.
  3. Enter the command to configure a credential helper.
  4. Enter commands to set up the username and email address.
  5. Log in to the DevOps portal using the same login credentials provided on the lab page.
  6. Click Continue.
  7. In Project Name, enter "LA-Git" and click + Create project.
  8. From the left menu, click Repos > Files.
  9. On the top menu, click LA-Git > + New repository.
  10. In the Create a new repository window, set the following values:

    • Repository name: Empty-Repo
    • Add a README to describe your repository: Select to enable
    • Add a .gitignore: VisualStudio
  11. Click Create.
  12. In the top right, click Clone.
  13. Copy the clone URL to the clipboard.
  14. Hit the keys Ctrl + Shift + P (Cmd + Shift + P on Mac).
  15. Select Git:Clone and paste the URL obtained from the cloning step.
  16. Provide the local path to the repo and click Select Repository Location.
  17. Log in using the same credentials obtained from the lab page.
  18. Click Open to open the cloned repository.
Install Azure Repos Extension for Visual Studio Code
  1. Open Visual Studio Code in VS-Studio-01.
  2. In the bottom left, click the gear icon > Extensions.
  3. From the Extensions list, select Azure Repos and click Install.
  4. Once installation completes, reload Visual Studio.
  5. Hit Ctrl + Shift + P (Cmd + Shift + P on Mac).
  6. Select Team:Signin.
  7. Select Authenticate and get an access token automatically.
  8. Copy the token provided and hit Enter to launch a browser tab.
  9. Paste the token and click Next.
  10. Sign in using the credentials provided on the lab page.
Commit File Changes
  1. Create a file in Repos and make changes to it.
  2. Click the Source Control icon to commit changes.
  3. Enter a commit message describing the changes made and hit Ctrl + Enter.
  4. If asked whether you would like to automatically stage your changes and commit them directly, click Always.
  5. In the bottom left, click the Synchronize icon and click OK to syncronize the changes.
Review and Compare Files Before Committing
  1. Make a change to the .gitignore file by adding a comment.
  2. Click the Source Control icon to view a side-by-side comparison of changes made before committing the new version of the file.
  3. Add a commit message and hit Ctrl + Enter.
  4. In the bottom left, click the Synchronize icon and click OK to syncronize the changes.
  5. Hit Ctrl + Shift + P (Cmd + Shift + P on Mac).
  6. Select Team:View History.
  7. When the dialog opens, click Open Link.
  8. From the left menu, click Commits to view commits made.

Additional Resources


Create a VM with Visual Studio

  1. Log in to the Azure portal.

  2. Click Create A Resource.

  3. Type "Visual Studio" in the search box.

  4. Select Visual Studio Community 2017 (Latest release) on Windows Server 2016.

  5. Click Create.

  6. Leave subscription as it is, and select the existing resource group.

  7. Set the following values:

    • Virtual machine name: VS-Studio-01
    • Size: B2S
    • Administrator user: Admin1234567
    • Administrator password: Admin1234567
  8. Make sure port 3389 is open in the select inbound ports section

  9. Select License type: Windows server Leave "Would you like to use an existing Windows Server license?": Unchecked.

  10. Review and click Create.

Download and install Git

If you are downloading the file directly to the Azure VM:

  1. Click Server Manager > Local Server > Enhanced Security Configuration.
  2. Click the link that says Off.
  3. Make sure the Off radio button is selected for administrators and users.
  4. Download Git and install it on VM(VS-Studio-01). Leave the default settings as you go through the wizard.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!