Connect a personal development environment to Git

更新时间:
复制 MD 格式

Data Studio integrates with Git repositories for version control and team collaboration. This topic shows you how to pull code from a remote repository, modify files, and push changes from your personal development environment.

Background

You can pull, add, modify, commit, push, and switch branches directly in Data Studio, eliminating the need for a separate Git client or command-line tool. This simplifies version control and team collaboration. For more information about using Git for source control, see Source Control with Git in Visual Studio Code.

Prerequisites

  • A serverless resource group is associated with your workspace. For details, see Use a serverless resource group.

  • A workspace is associated with compute resources. For details, see create a workspace and associate compute resources.

  • A personal development environment is created. For details, see personal development environment.

Billing

Your personal development environment incurs compute charges based on its configured compute unit (CU) quota and runtime. For details, see billing of serverless resource groups.

Important

Your personal development environment incurs compute charges while running. To avoid unnecessary costs, stop the environment on the instance management page when you are not using it.

Usage notes

  • You can only select personal development environments created by the currently logged-in Alibaba Cloud account.

  • During source control operations, follow the on-screen prompts to enter the username and password for your remote Git repository to authenticate. Failure to do so results in a Failed to authenticate to git remote error.

Step 1: Enter 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. Enter the personal development environment.

    In the top navigation bar, click the image icon next to Select Personal development environment, and then click the name of the environment you want to enter.

    Important

    Before you enter the personal development environment, ensure it is in the running state. Otherwise, Data Studio displays the message the current environment is unavailable.

Step 2: Initialize and use Git

  1. Click the image icon in the lower-left corner of the data development page to open the terminal.

  2. In the Terminal tab, follow the instructions in Git Setup to initialize the Git repository and set your Git commit username and email address. For example, run the following commands:

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

    Replace the placeholder username and email address with your actual information.

  3. Clone your Git repository. In the terminal, run the following command. When prompted, enter your Username and Password.

    git clone https://xxx.git
    Note

    You must replace https://xxx.git with the URL of your Git repository.

  4. After the repository is cloned, you can edit its files in the Personal Directory section on the data development (image) pane. Commit changes by running commands in the Terminal or by using the graphical user interface (GUI) of the source control menu. For specific commands, see Source Control with Git in Visual Studio Code.

    For example, enter the following SQL statement in the editor for the select.sql file:

    SELECT "125"

    In the terminal, run the ll command to view the directory structure of the workspace:

    /mnt/workspace> ll
    drwxrwxrwx 2 root root 4096 xxx xxx xxx/
    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/
    /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/
    /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/
    /mnt/workspace> cd .