Exercise - Clone a repository and gain context

Completed

Let's see how you can use Visual Studio Code to start a new project by cloning the project from an existing repository on GitHub.

Step 1: Clone a new repository from GitHub

  1. Open a new Visual Studio Code window. From the Explorer view, you can select Clone Repository. You should see an option to clone from GitHub.

    Screenshot that shows the Clone from GitHub option on the Visual Studio Code Command Palette.

  2. Select the Clone from GitHub option from the dropdown list, and you'll find a list of your repositories. You can also search for other repositories on GitHub. Search for a repository by using the path MicrosoftDocs/mslearn-python-products and select the first option.

    Screenshot of the Explorer view in Visual Studio Code, with the Clone Repository button outlined and the Clone from GitHub option on the command palette.

  3. Choose a location on your computer where you want the repository to be cloned.

  4. Select Open from the pop-up that appears after Visual Studio Code has cloned the repository.

    Screenshot of a notification in Visual Studio Code asking to open the cloned repository, with the Open button outlined.

Step 2: Compare changes in the commit history to gain context

  1. Open the README.md file from the Explorer. After you have the file in the editor, expand the Timeline pane.

    Screenshot that shows the Explorer icon in Visual Studio Code.

  2. Select the commit made by the user Burke Holland. This step opens a read-only diff view so you can see all the changes associated with the commit. The green highlight shows that Burke has added those lines to the original content.

    Screenshot of the Visual Studio Code diff editor, showing the differences in a file between two commits.

What you just did

Let's recap what you did in this section:

  • Cloned a GitHub repo to your computer using Visual Studio Code
  • Reviewed changes made to a file using the Timeline pane in Visual Studio Code