Git Visual Studio Code

  

Visual Studio Code has integrated source control management (SCM) and includes Git support in-the-box. Many other source control providers are available through extensions on the VS Code Marketplace. Tip: Click on an extension tile to read the description and reviews in the Marketplace.

Using GitHub with Visual Studio Code lets you share your source code and collaborate with others. GitHub integration is provided through the GitHub Pull Requests and Issues extension.

To get started with the GitHub in VS Code, you'll need to create an account and install the GitHub Pull Requests and Issues extension. In this topic, we'll demonstrate how you can use some of your favorite parts of GitHub without leaving VS Code.

A GitHub account. Basic knowledge of Git concepts such as repositories and cloning, as described in Using Git version control tools in Visual Studio Code. Visual Studio Code. Introduction 2 min. Lesson - Sign in to GitHub 2 min. Exercise - Sign in to GitHub 2 min. Lesson - Publish your repository 2 min. Exercise - Create a repository. Open an existing Git repository. If your code is already on your machine, you can open it by using File Open Project/Solution (or Folder) and Visual Studio automatically detects if it has an initialized Git repository. Create a new Git repository. If your code is not associated with Git. Using GitHub with Visual Studio Code lets you share your source code and collaborate with others. GitHub integration is provided through the GitHub Pull Requests and Issues extension. Install the GitHub Pull Requests and Issues extension.

If you're new to source control and want to start there, you can learn about VS Code's source control integration.

Getting started with GitHub Pull Requests and Issues

Once you've installed the GitHub Pull Requests and Issues extension, you'll need to sign in. Follow the prompts to authenticate with GitHub in the browser and return to VS Code.

Git visual studio code windows

If you are not redirected to VS Code, you can add your authorization token manually. In the browser window, you will receive your authorization token. Copy the token, and switch back to VS Code. Select Signing in to github.com... in the Status bar, paste the token, and hit Enter.

Setting up a repository

Cloning a repository

You can search for and clone a repository from GitHub using the Git: Clone command in the Command Palette (β‡§βŒ˜P (Windows, Linux Ctrl+Shift+P)) or by using the Clone Repository button in the Source Control view (available when you have no folder open).

Authenticating with an existing repository

Enabling authentication through GitHub happens when you run any Git action in VS Code that requires GitHub authentication, such as pushing to a repository that you're a member of or cloning a private repository. You don't need to have any special extensions installed for authentication; it is built into VS Code so that you can efficiently manage your repository.

When you do something that requires GitHub authentication, you'll see a prompt to sign in:

Follow the steps to sign into GitHub and return to VS Code. If authenticating with an existing repository doesn’t work automatically, you may need to manually provide a personal access token. See Personal Access Token authentication for more information.

Note that there are several ways to authenticate to GitHub, including using your username and password with two-factor authentication (2FA), a personal access token, or an SSH key. See About authentication to GitHub for more information and details about each option.

Editor integration

Hovers

When you have a repository open and a user is @-mentioned, you can hover over that username and see a GitHub-style hover.

There is a similar hover for #-mentioned issue numbers, full GitHub issue URLs, and repository specified issues.

Suggestions

User suggestions are triggered by the '@' character and issue suggestions are triggered by the '#' character. Suggestions are available in the editor and in the Source Control view's input box.

The issues that appear in the suggestion can be configured with the GitHub Issues: Queries (githubIssues.queries) setting. The queries use the GitHub search syntax.

You can also configure which files show these suggestions using the settings GitHub Issues: Ignore Completion Trigger (githubIssues.ignoreCompletionTrigger) and GitHub Issues: Ignore User Completion Trigger (githubIssues.ignoreUserCompletionTrigger). These settings take an array of language identifiers to specify the file types.

Pull requests

Visual Studio Git Plugin

From the Pull Requests view you can view, manage, and create pull requests.

The queries used to display pull requests can be configured with the GitHub Pull Requests: Queries (githubPullRequests.queries) setting and use the GitHub search syntax.

Creating Pull Requests

You can use the GitHub Pull Requests: Create Pull Request command or use the + button in the Pull Requests view to create a pull request. If you have not already pushed your branch to a remote, the extension will do this for you. You can use the last commit message, the branch name, or write a custom title for the pull request. If your repository has a pull request template, this will automatically be used for the description.

Reviewing

Pull requests can be reviewed from the Pull Requests view. You can assign reviewers and labels, add comments, approve, close, and merge all from the pull request description.

From the description page, you can also easily checkout the pull request locally using the Checkout button. This will add a new Changes in Pull Request view from which you can view diffs of the current changes as well as all commits and the changes within these commits. Files that have been commented on are decorated with a diamond icon. To view the file on disk, you can use the Open File inline action.

The diff editors from this view use the local file, so file navigation, IntelliSense, and editing work as normal. You can add comments within the editor on these diffs. Both adding single comments and creating a whole review is supported.

Issues

Creating issues

Issues can be created from the + button in the Issues view and by using the GitHub Issues: Create Issue from Selection and GitHub Issues: Create Issue from Clipboard commands. They can also be created using a Code Action for 'TODO' comments.

Visual Studio Code Git Clone

You can configure the trigger for the Code Action using the GitHub Issues: Create Issue Triggers (githubIssues.createIssueTriggers) setting.

The default issue triggers are:

Working on issues

Git Visual Studio Code Default Editor

From the Issues view, you can see your issues and work on them. By default, when you start working on an issue, a branch will be created for you. You can configure the name of the branch using the GitHub Issues: Working Issue Branch (githubIssues.workingIssueBranch) setting. The commit message input box in the Source Control view will be populated with a commit message, which can be configured with GitHub Issues: Working Issue Format SCM (githubIssues.workingIssueFormatScm).

If your workflow doesn't involve creating a branch, or if you want to be prompted to enter a branch name every time, you can skip that step by turning off the GitHub Issues: Use Branch For Issues (githubIssues.useBranchForIssues) setting.

Git Visual Studio Code Terminal

GitDuck is a video chat tool built for developers that has direct integration to the IDE so you can talk, share your code in real-time and easily collaborate with your team. It enables remote developers to work as if they were side by side.

With GitDuck you can code with people using different IDEs, like VSCode or WebStorm, IntelliJ or PyCharm. Review our website for the complete list of supported IDEs.

The code is only shared P2P encrypted with the video call participants. No data touches our servers.

Watch how to start sharing your code on GitDuck

GitDuck is great for:

  • Remote teams
  • Mentoring and leaning to code
  • Pair Programming
  • Code reviews
  • Debugging

✨ Features

πŸ”Ž Locate other developers

  • Click on someone's name to locate that person.

πŸ”§ Share your terminal

  • Share your servers output and your current terminal session with the GitDuck shell.

πŸ‘€ Follow and Unfollow

  • Check the people's panel and select to follow someone. Now you are going to be seeing everything that this person does.

πŸ”Ž Share project or specific folder

  • Select to share open files only, a specific folder or the whole project.

πŸ—‚ Review all files that are being shared

  • Once shared, you can easily view all files that are open by everyone.

πŸ”’ P2P code sharing

  • The code is shared P2P encrypted between the video call participants and only team members can join the call.

Installation

  1. Create a GitDuck account on https://gitduck.com and create a team.
  2. On VS Code search for GitDuck in the markeplace and install the GitDuck extension for VS Code.
  3. Now in the bottom right of your VS Code you will have an option that says: 'Login on GitDuck'. Click there to link your VS Code to your GitDuck account.
  4. Great! Now you can join a video call on GitDuck and share your code to any person that joins the call and also installed the extension (they could be using another IDE).

If you still have any questions, watch this tutorial on how to install GitDuck and use it for the first time.

How to start pair programming?

  1. Did you install the extenion? Check the installation above.
  2. Just go to your team page on GitDuck and will be able to start a video call there.
  3. Once you are in a video call, check the bottom right of your VSCode for the option to share your code.

Requirements

GitDuck works for:

  • MacOS (Intel and Apple chip) 10.12 or greater.
  • Windows 7, 8 and 10.
  • Linux.

Do you need help?

If you face any issues, don't hesitate to contact us at help @ gitduck.com

Thank you!