Exercise - Clone a repository and gain context

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.

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 drop-down 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.

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.