Using the integrated Git

Prerequisites

To use the features that involve Git, you must install Git and have it available in your system path so that VS Code can display it. On Macs, Git comes out of the box. On Linux, you can install Git with your distribution's package manager. On Windows, you can get Git from https://git-scm.comopen in new window.

Creating Git branches

To manage your codes for parallel development, you can create a new branch using the integrated Git. To create a new Git branch:

  1. Select the branch icon at the lower left of the browser page in the colored status bar. A drop-down box at the top of the browser page appears with various options.
  2. Select the branch icon at the bottom again and then Create new branch....
  3. Enter the name of the new branch.

Committing changes into Git branches

After making code changes and refinements, you can commit changed files to the Git repository.

To commit changed files:

  1. Open the Git view by clicking View > Git, or pressing Ctrl+Shift+G (Windows and Mac), which lists all the files that you added or modified.

  2. To review changes to a changed file that is marked by the M, double-click the file to open a diff editor view.

  3. Take one of the following actions:

    • Open the file.
    • Discard changes.
    • Add your file for the next commit that is called Staging by clicking the + icon to stage it.
  4. Provide a short description in the Commit message text box at the top, such as Implemented Update Report.

  5. Make sure that the branch you want to commit to is selected at the bottom of the browser page.

  6. Click Commit on the top of the Git view. The list of files is empty now as all changes were committed to the branch.

You can review these changes in the Git History viewer after completing the commit.

For more information about using Git, see VS Code documentationopen in new window.

Last Updated:
Contributors: Peter Haumer, Shi Kun Li