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.
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 remoteerror.
Step 1: Enter the personal development environment
Go to the Workspaces page in the DataWorks console. In the top navigation bar, select a desired region. Find the desired workspace and choose in the Actions column.
-
Enter the personal development environment.
In the top navigation bar, click the
icon next to Select Personal development environment, and then click the name of the environment you want to enter.ImportantBefore 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
-
Click the
icon in the lower-left corner of the data development page to open the terminal. -
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.comNoteReplace the placeholder username and email address with your actual information.
-
Clone your Git repository. In the terminal, run the following command. When prompted, enter your
UsernameandPassword.git clone https://xxx.gitNoteYou must replace
https://xxx.gitwith the URL of your Git repository. -
After the repository is cloned, you can edit its files in the Personal Directory section on the data development (
) 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.sqlfile:SELECT "125"In the terminal, run the
llcommand 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 .