Connect a personal development environment to a Git repository
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
A serverless resource group is created and associated with a workspace. For instructions, see Use a serverless resource group.
A workspace is created and associated with compute resources.
A personal development environment is created. For instructions, see Personal development environment.
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.
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
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.
In the top navigation bar, click the
icon next to Select Personal development environment, and then click the personal development environment that you created.ImportantMake 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
On the data development page, click the
button on the left side of the lower-left sidebar to open the terminal.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.comNoteReplace the username and email address with your actual information.
Step 3: Clone the remote Git repository
In the terminal, run the following command:
git clone https://xxx.gitNoteReplace
https://xxx.gitwith the URL of your Git repository.Enter the
UsernameandPasswordof the remote Git repository as prompted, and then press Enter to complete the identity verification.ImportantIf you do not complete the identity verification, the
Failed to authenticate to git remoteerror message appears.To check the result, run the
llcommand 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
After the repository is cloned, edit the files of the repository under Personal Directory in the data development (
) 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"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.