Version Control

Eclipse Che natively supports the VS Code SCM model. By default, Eclipse Che includes the native VS Code Git extension as a Source Code Management (SCM) provider.

Managing Git configuration: identity

The first thing to do before starting to use Git is to set a user name and email address. This is important because every Git commit uses this information.

Procedure
  • To configure Git identity using the Che user interface:

    1. Open File > Settings > Open Preferences or press Ctrl+,.

      Configuring Git identity
    2. In the opened window, navigate to the Git → User sub-section and enter the User mail and User name values.

  • To configure Git identity using the command line, open the terminal of the Che-Theia container.

    1. Navigate to the My Workspace view, and open Plugins > theia-ide…​ > New terminal:

      terminal git command
    2. Execute the following commands:

      $ git config --global user.name "John Doe"
      $ git config --global user.email johndoe@example.com

Che-Theia permanently stores this information in the current container and restores it for other containers on future workspace starts.

Accessing a Git repository using HTTPS

Procedure

To clone a repository using HTTPS:

  1. Use the clone command provided by the Visual Studio Code Git extension.

Alternatively, use the native Git commands in the terminal to clone a project.

  1. Navigate to destination folder using the cd command.

  2. Use git clone to clone a repository:

    $ git clone <link>

    Eclipse Che supports Git self-signed TLS certificates. See Deploying Che with support for Git repositories with self-signed certificates to learn more.

Accessing a Git repository using a generated SSH key pair

Generating an SSH key using the Che command palette

The following section describes a generation of an SSH key using the Che command palette and its further use in Git provider communication. This SSH key restricts permissions for the specific Git provider, therefore, the user has to create a unique SSH key for each Git provider in use.

Prerequisites
Procedure

A common SSH key pair that works with all the Git providers is present by default. To start using it, add the public key to the Git provider.

  1. Generate an SSH key pair that only works with a particular Git provider:

    • In the Che IDE, press F1 to open the Command Palette, or navigate to View → Find Command in the top menu.

      The command palette can be also activated by pressing Ctrl+Shift+p (or Cmd+Shift+p on macOS).

    • Search for SSH: generate key pair for particular host by entering generate into the search box and pressing Enter once filled.

    • Provide the hostname for the SSH key pair such as, for example, github.com.

      The SSH key pair is generated.

  2. Click the View button in the lower-right corner and copy the public key from the editor and add it to the Git provider.

    It is possible to use another command from the command palette: Clone git repository by providing an SSH secured URL.

Adding the associated public key to a repository or account on GitHub

To add the associated public key to a repository or account on GitHub:

  1. Navigate to github.com.

  2. Click the drop-down arrow next to the user icon in the upper right corner of the window.

  3. Click SettingsSSH and GPG keys and then click the New SSH key button.

  4. In the Title field, type a title for the key, and in the Key field, paste the public key copied from Che.

  5. Click the Add SSH key button.

Adding the associated public key to a Git repository or account on GitLab

To add the associated public key to a Git repository or account on GitLab:

  1. Navigate to gitlab.com.

  2. Click the user icon in the upper right corner of the window.

  3. Click SettingsSSH Keys.

  4. In the Title field, type a title for the key and in the Key field, paste the public key copied from Che.

  5. Click the Add key button.

Managing pull requests using the GitHub PR plug-in

To manage GitHub pull requests, the VS Code GitHub Pull Request plug-in is available in the list of plug-ins of the workspace.

Using the GitHub Pull Requests plug-in

Prerequisites
Procedure
  • Sign in to GitHub, using the Accounts menu or the Sign in button in the plugin’s view:

    github sign in action

To sign out from GitHub use the Accounts menu in the left bottom side, or GitHub Pull Requests: Sign out of GitHub command.