Importing the source code of a project into a workspace

With Che, you can import and work on a project’s current codebase in a workspace.

You can import a project’s codebase into a workspace by using any of the following options:

Prerequisites

Importing a project when creating a workspace

You can import a project’s codebase while creating a new workspace: by using a devfile template and the project’s URL.

Procedure
  1. Go to the Dashboard of Che.

  2. In the left navigation panel, click Create Workspace.

  3. Go to the Custom Workspace tab.

  4. Enter a workspace name.

    If you do not enter a Workspace Name for your workspace, Che generates a unique name for a new workspace from the devfile’s metadata.generateName property followed by four random characters.

  5. Select a devfile template from the drop-down list.

    Select a devfile from the list
  6. Edit the projects section of the template devfile displayed in the devfile editor on the page.

    Edit the projects section of the devfile
    Example 1. Editing the projects section of a devfile
    projects:
      - name: che
        source:
          type: git
          location: 'https://github.com/eclipse-che/che-server.git'

    For more information about devfiles, see Authoring a devfile 2.0.0.

  7. Click Create & Open.

  8. Wait for the initialized workspace to start and for the IDE to open.

Importing a project into a created workspace

You can import a project’s codebase into a created workspace by editing its devfile.

Prerequisites
  • A running workspace

Procedure
  1. Go to the Dashboard of Che.

  2. Under RECENT WORKSPACES, hover over the name of the workspace to which you will import the project.

  3. Click the three dots.

  4. Select Edit Workspace.

  5. In the Devfile tab, edit the projects section of the devfile in the editor on the page.

    Example 2. Editing the projects section of a devfile
    projects:
      - name: che
        source:
          type: git
          location: 'https://github.com/eclipse-che/che-server.git'

    For more information about devfiles, see Authoring a devfile 2.0.0.

  6. Click Save.

Adding commands to an imported project

You can add commands to a project that will enable running, debugging, or starting an application in a browser.

Prerequisites
  • A workspace with a project in it

Procedure
  1. Go to the Dashboard of Che.

  2. Under RECENT WORKSPACES, hover over the name of the workspace to which you will import the project.

  3. Click the three dots next to the workspace name.

  4. Select Edit Workspace.

  5. In the Devfile tab, edit the commands section of the devfile in the editor on the page.

  6. Click Save.

  7. Open the workspace.

  8. To run a command, select Terminal > Run Task from the main menu.

    Run task
  9. To configure commands, select Terminal > Configure Tasks from the main menu.

    Configure tasks

Importing a project with Git: Clone in the GUI

You can import a project’s codebase into a running workspace with the Git: Clone command in the graphic user interface of Che.

Prerequisites
  • A started workspace

Procedure
  1. Select the Git: Clone command on the Welcome screen or from the command palette:

    • On the Welcome screen, click the Git: Clone link.

      Welcome screen
    • To open the command palette, press F1 or Ctrl+Shift+P (Cmd+Shift+P on macOS).

      Invoke git clone command
  2. Enter the path to the project that you want to clone.

    Configure git clone command

Importing a project with git clone in a terminal

You can use the command line to import a project’s codebase into a running workspace.

Prerequisites
  • A running workspace

Procedure
  1. Open a terminal inside the running workspace.

  2. Type the git clone command to pull code.

    Run git clone in a terminal

Importing or deleting workspace projects in the terminal does not update the workspace configuration, and the IDE does not reflect the changes in the Devfile tab in the dashboard.

Similarly, when you add a project in the Dashboard and then delete the project with the rm -fr myproject command, the project may still appear in the Devfile tab.