Connect a personal development environment to a Git repository

Updated at:

Connect a personal development environment in Data Studio to a remote Git repository to simplify source code version management and team collaboration. Configure Git, clone the remote repository, and then edit and commit code without leaving the personal development environment.

Background information

Data Studio integrates personal development environments with remote Git repositories. In a personal development environment, you can pull, add, modify, and commit code and switch branches without installing a separate Git client or using an external command line interface. The following sections describe Git configuration, repository cloning, and code editing and committing. For the Git operations that this topic does not describe step by step, such as pulling updates, pushing commits, and switching branches, see Source Control with Git in Visual Studio Code.

Prerequisites

Usage notes

  • You can select only the personal development environments that are created by the Alibaba Cloud account that you use to log on.

  • When you perform source control operations, enter the logon name and password of the remote Git repository as prompted to complete identity verification.

Billing

A personal development environment is charged for compute resources based on the compute unit (CU) quota that you configure for it and on its runtime. For more information, see Billing of serverless resource groups.

Important

Compute fees are charged as long as the personal development environment is in the Running state. Stop the environment on the instance management page as soon as you no longer need it.

Step 1: Go to the personal development environment

  1. Go to the Workspaces page in the DataWorks console. In the top navigation bar, select a desired region. Find the desired workspace and choose Shortcuts > Data Studio in the Actions column.

  2. In the top navigation bar, click the image icon next to Select Personal development environment, and then click the personal development environment that you created.

    Important

    Make sure that the personal development environment is in the Running state before you enter it. Otherwise, the message The current environment is unavailable appears.

Step 2: Configure your Git commit identity

  1. On the data development page, click the image button on the left side of the lower-left sidebar to open the terminal.

  2. In the Terminal tab, set the username and email address for your Git commits, as described in Git Setup. For example, run the following commands:

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

    Replace the username and email address with your actual information.

Step 3: Clone the remote Git repository

  1. In the terminal, run the following command:

    git clone https://xxx.git
    Note

    Replace https://xxx.git with the URL of your Git repository.

  2. Enter the Username and Password of the remote Git repository as prompted, and then press Enter to complete the identity verification.

    Important

    If you do not complete the identity verification, the Failed to authenticate to git remote error message appears.

  3. To check the result, run the ll command in the terminal and view the structure of the workspace directory:

    /mnt/workspace> ll
    total 16
    drwxr-xr-x 4 root root 4096 xxx
    drwxr-xr-x 1 root root 4096 xxx
    drwxrwxrwx 4 root root 4096 xxx
    drwxrwxrwx 2 root root 4096 xxx xxx/

Step 4: Edit and commit the code

  1. After the repository is cloned, edit the files of the repository under Personal Directory in the data development (image) pane on the left.

    For example, open a file of the repository, such as select.sql, and enter the following SQL statement in the editor:

    SELECT "125"
  2. Commit your changes to Git in either of the following ways:

    • Terminal — Run Git commands in the Terminal tab.

    • Source control menu — Use the graphical interface of the source control menu.

    For the commands to use, see Source Control with Git in Visual Studio Code.