GitHub integration in Visual Studio Code

Completed

There are a variety of ways that you might use GitHub with a project. Sometimes, you might clone a project to get a copy of it so that you can work on it locally. In other cases, you might start working on a project locally and then decide to put it on GitHub so that you can share your work with others.

Before you can do anything with GitHub, you have to authenticate to GitHub. Normally, authentication can be a tedious, multi-step process that involves generating and working with SSH keys. One benefit of using Visual Studio Code to work with GitHub is that it handles all of the authentication setup for you.

You'll sign in and authenticate to GitHub in the next unit. In this unit, we present an overview of how GitHub and Visual Studio Code are integrated to facilitate authentication and how to begin using the tools together.

Authenticate to GitHub through Visual Studio Code

To begin working with GitHub through Visual Studio Code, you'll first need to search for and install one or more GitHub extensions from the Visual Studio Code Marketplace. For this training module, we'll use the GitHub Pull Requests and Issues extension. However, there are many other extensions available, such as GitHub Repositories, GitHub Copilot, and GitHub Codespaces.

After installing the appropriate GitHub extensions in Visual Studio Code, you can initiate authentication by selecting the account icon that's at the bottom of the activity bar and signing in with your GitHub account (we'll do this in the next unit). A browser opens, and you're asked to grant permission for Visual Studio Code to access GitHub.

This step is needed to connect Visual Studio Code to GitHub. It doesn't store any sensitive information. After granting permission for Visual Studio Code to access GitHub, you're redirected back to Visual Studio Code.

When you sign in to your GitHub account in Visual Studio Code, various extensions or parts of Visual Studio Code can now access your GitHub account information. You can choose which Visual Studio Code extensions are allowed to use your GitHub authentication and revoke GitHub access from the extensions at any time.

Work with GitHub repositories using Visual Studio Code

After you've signed in to GitHub, Visual Studio Code will now help you with starting and publishing a repository to your GitHub account with a push of a button. It will also let you search for repositories you've created on GitHub so you can clone them locally.

There are even more GitHub features in the GitHub Pull Requests and Issues extension. In this module, we'll explore the built-in ones first.