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.

Prerequisites
  • The Visual Studio Code Git extension installed.

Procedure

To configure Git identity using the Che user interface, go to in Preferences.

  1. Open File > Settings > Open Preferences:

    git config identity
  2. In the opened window, navigate to the Git section, and find:

     user.name
     user.email

    And configure the identity.

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 and restores it on future workspace starts.

Accessing a Git repository via HTTPS

Prerequisites
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>
Self-signed SSL certificates are not supported. Use SSH keys instead.

Accessing a Git repository via SSH

Prerequisites

Generating an SSH key

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

To generate an SSH key pair that only works with a particular Git provider:

  1. Run the SSH: generate key pair for particular host command.

  2. After the key is generated, click the View button and copy the public key from the editor.

  3. Add the public key to the Git provider.

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 top-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.

    che theia basics ssh

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 top-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.

    che theia basics ssh keys

Configuring GitHub OAuth

OAuth for Github allows users to clone projects using SSH addresses (git@) and push to repositories.

Procedure

To enable automatic SSH key upload to GitHub for users:

  1. On github.com, click your user icon (top right).

  2. Go to Settings > Developer settings > OAuth Apps.

  3. Click the Register a new application button.

  4. In the Application name field, enter, for example, Eclipse Che.

  5. In the Homepage URL field, enter http://$\{CHE_HOST}:$\{CHE_PORT}.

  6. In the Authorization callback URL field, enter http://$\{CHE_HOST}:$\{CHE_PORT}/api/oauth/callback.

    github oauth
  7. On OpenShift or Kubernetes, update the deployment configuration (see OpenShift configuration).

    CHE_OAUTH_GITHUB_CLIENTID=<your-github-client-id>
    CHE_OAUTH_GITHUB_CLIENTSECRET=<your-github-secret>
  • Substitute all occurrences of ${CHE_HOST} and ${CHE_PORT} with the URL and port of your Che installation.

  • Substitute <your-github-client-id> and <your-github-secret> with your GitHub client ID and secret.

  • This configuration only applies to single-user deployments of Che.

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

  1. Authenticate by running the GitHub Pull Requests: Manually Provide Authentication Response command and paste the GitHub token.

  2. Select the repository permissions when generating the token.

Creating a new pull request

  1. Open the GitHub repository. To be able to execute remote operations, the repository must have a remote with an SSH URL.

  2. Checkout a new branch and make changes that you want to publish.

  3. Run the GitHub Pull Requests: Create Pull Request command.

Tags: