Creating a workspace by importing the source code of a project

This section describes how to create a new workspace for editing an existing codebase.

Prerequisites
  • A running instance of Che. To install an instance of Che, see Installing Che.

  • An existing workspace with plug-ins related to your development environment defined on this instance of Eclipse Che Configuring a Che 7.29 workspace.

A user can progress with two methods that have to be applied before starting a workspace:

To create a new workspace for editing an existing codebase, use one of the following methods after the workspace has been started:

Select a sample from the Dashboard, then change the devfile to include your project

  • In the left navigation panel, go to Get Started.

  • In a case it’s not selected already, click the Custom Workspace tab.

  • In the Devfile section, select the devfile template that will be used to build and run projects.

    Select a devfile from the list
  • In the Devfile editor, update projects section:

    Update projects section of the devfile
    Example: add a project

    To add a project into the workspace, add or edit the following section:

    projects:
      - name: che
        source:
          type: git
          location: 'https://github.com/eclipse/che.git'
  • To open the workspace, click the Create & Open button.

Importing from the Dashboard into an existing workspace

  • From the Dashboard, select Workspaces.

  • Select your workspace by selecting its name. This will link you to the workspace’s Overview tab.

  • Open Devfile tab where you can enter your own YAML configuration.

  • Add the project.

Example: add a project

To add a project into the workspace, add or edit the following section:

projects:
  - name: che
    source:
      type: git
      location: 'https://github.com/eclipse/che.git'

Editing the commands after importing a project

After you have a project in your workspace, you can add commands to it. Adding commands to your projects allows you to run, debug, or start your application in a browser.

To add commands to the project:

  1. Open the workspace configuration in the Dashboard, then select the Devfile tab.

  2. Modify the commands field.

  3. Open the workspace.

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

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

    Configure tasks

Importing to a running workspace using the Git: Clone command

To import to a running workspace using the Git: Clone command:

  1. Start a workspace, then use the Git: Clone command from the command palette or the Welcome screen to import a project to a running workspace.

    Welcome screen
  2. Open the command palette by using F1, CTRL-SHIFT-P, or the link displayed on the Welcome screen.

    Invoke git clone command
  3. Enter the path to the project that is about to be cloned.

    Configure git clone command

Importing to a running workspace with git clone in a terminal

In addition to the approaches above, you can also start a workspace, open a Terminal, and type git clone 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 Project and Devfile tabs in the dashboard.

Similarly, when you add a project using the Dashboard, then delete it with rm -fr myproject, it may still appear in the Projects or Devfile tab.