Code repository usage issues

Updated at:

This topic answers common questions about using code repositories in Apsara DevOps. It explains the difference between committers and authors, how to perform code rollbacks, and how to simplify repository addresses. You can also find solutions for Go dependency management, TortoiseGit errors, and associating tasks with commits. Additionally, this topic covers integrating with Jenkins, associating Flow pipelines, using Alibaba Cloud Container Registry (ACR), writing regular expressions, linking existing folders, downloading repositories in batches, ignoring files during merges, and handling repository imports and migrations.

Difference between a committer and an author

In Git, every commit has an author and a committer. These can be two different people. Understanding the difference helps you maintain a clean commit history. For more information, see What is the difference between a committer and an author?

  • Author: The person who originally created the changes.

  • Committer: The person who submitted the changes to the repository. In an email-based workflow, this is often the project maintainer.

Configuration method:

git config --global user.name "Your Name"
git config --global user.email your.name@example.com

Validating and modifying:

  • Use git log --pretty=fuller to view detailed commit information.

  • Modify the committer's email for the latest commit: git commit --amend.

  • To modify the email of the author or committer, run the following command: git commit --reset-author --amend.

  • Change information in historical commits: Use the git rebase -i command for an interactive rebase.

Roll back code

Background: If an unexpected merge or commit introduces errors into your code, you can use the revert or reset command to restore a previous version. For more information, see How do I roll back code?

  • revert command: Reverses the changes from a specific commit but keeps the commit history.

  • reset command: Rolls back to a specific commit and erases all commit history after that point. You must force push the changes to the remote repository.

If a remote branch was accidentally rolled back to an older version, you can find the correct commit ID and create a new branch to overwrite the remote branch. If a remote branch contains unintended content from an earlier merge, you can find the commit that you want to restore.

Simplify repository addresses

Background: The organization ID in Apsara DevOps can make URLs hard to remember. You can set a custom organization name to simplify repository addresses.

Procedure:

  • Go to Codeup Homepage > Global Settings > General Settings > Organization Personalization.

  • Set a custom organization name to replace the default organization ID. You can use a meaningful name.

  • Note: You can set the organization name only once. Choose it carefully.

For more information about the procedure, see What do I do if my repository address has a long, random ID?

Go dependency management

Background: To ensure the security of your organization's data, you must handle authentication when you manage Go dependencies.

  • .netrc file: Stores authentication information, such as usernames and passwords, for automatic logon.

  • Best practice: Configure an HTTPS clone username and password for Codeup. Store them in the .netrc file for security and convenience. For more information, see How do I use Go dependency management?

Troubleshoot TortoiseGit tool errors

Common issue: If you cannot push or pull code using TortoiseGit, the problem might be an incorrect Secure Shell (SSH) key configuration.

Solution:

  • Change the SSH client to OpenSSH instead of TortoiseGitPlink.

  • Confirm that the public key is added to Pageant in your local PuTTY installation.

For more information about the operations, see How do I handle errors related to the TortoiseGit tool?

Associate requirements, tasks, or bugs with a commit

Associating relevant requirements, tasks, or bugs when you commit code improves tracking and management efficiency. For more information, see Code association in tasks.

Integrate with Jenkins for continuous integration

Overview: Integrate your Codeup repository with Jenkins to automate your build, test, and deployment processes. For more information, see How do I integrate with Jenkins for continuous integration?

Associate a Flow pipeline in Codeup

Overview: Associate your Codeup repository with a Flow pipeline to automate build, test, and deployment processes and improve development efficiency.

Create a pipeline:

  • Method 1: Go to the target repository, click the Pipelines tab, and then click New Pipeline.

  • Method 2: From the menu in the upper-left corner, select Pipelines, and then click New Pipeline. For the code source, select Codeup.

Select a code source: On the creation page, select Codeup as the code source and follow the prompts to enter the required configuration information.

Automatic triggering event: To automatically run the pipeline for every commit, select the Automatically trigger on code commit checkbox.

Complete the association: After the pipeline is triggered for the first time, the relevant information is synchronized to the specified repository in Codeup. This completes the association.

Rich detection services: You can use Flow pipelines to add support for more types of checks and services, such as static code analysis and security scans.

For more information about the operations, see How do I associate a Flow pipeline?.

Use Alibaba Cloud Container Registry (ACR)

Background: Codeup integrates with Alibaba Cloud Container Registry (ACR) to better support the development process for containerized applications.

Procedure:

  1. Create a new image repository in the ACR console.

  2. In the Flow pipeline configuration, select Codeup as the code source.

  3. Authorize the Flow pipeline to use ACR tasks and select the corresponding image repository.

This method lets you use the stable and reliable container image hosting service from ACR. You can also combine it with Apsara DevOps pipelines to automate build and release processes. For more information, see How do I use Alibaba Cloud Container Registry (ACR)?

Regular expressions

Syntax support: Codeup supports only RE2 syntax. RE2 is a lightweight and efficient regular expression engine. Its rules are slightly different from PCRE. Note that matching is case-sensitive by default.

For more information about the syntax and specific usage, see How to write regular expressions.

Associate an existing folder or repository

Associate a local folder: To quickly associate an existing local project folder and push it to the cloud, run the following commands:

cd existing_folder
git init
git remote add origin https://codeup.aliyun.com/xxx/xxx.git
git add .
git commit -m "Initial commit"
git push -u origin master

Import a third-party repository: There are two ways to import a repository hosted on another platform:

  • Use the command line to clone the remote repository with git clone --bare. Then, set the new remote URL and push all branches and tags with git push --mirror.

  • Use the Import Repository feature on the Codeup web UI to import directly from an external repository URL.

For more information, see How do I associate an existing folder or repository?

Download multiple repositories in batches

Solution: The git-repo service supports batch downloads. This is useful when you need to manage multiple related Git repositories at the same time. For more information, see AGit-Flow Alibaba's centralized Git workflow.

Ignore files during a merge

Local merge strategy: Server-side merge requests do not directly support ignoring specific files. However, you can achieve this result during a local merge by configuring the .gitattributes file. For example, to prevent a file from being updated during a merge, add the following configuration to the .gitattributes file in the file's directory:

# Prevents the file demo.txt in the root directory of the dev branch from being merged into the master branch
demo.txt merge=ours
# Prevents the file /common/src/main/resources/demo.yml in the dev branch from being merged into the master branch.
/common/src/main/resources/demo.yml merge=ours

Then, before you merge, run the command git config merge.ours.driver true to enable this strategy. Finally, perform the merge as usual. For more information, see How do I ignore files during a merge?

Repository import and migration FAQ

Network connectivity issues: If an import from a self-hosted GitLab instance fails with a "cannot connect" error, use one of the following solutions:

  • Recommended solution: Use the official Apsara DevOps tool for importing on-premises repositories. This does not require public network access.

  • Alternative solution: Adjust your GitLab configuration to expose a public clone address. This ensures that Apsara DevOps can pull the code.

Cross-organization migration: To migrate a repository from one Apsara DevOps organization to another, you can import it by URL. On the repository homepage of the target organization, click Import Repository. Select Import by URL, and then follow the instructions to enter the source repository's HTTPS address and authentication information.

For more information about the operations, see Repository import and migration FAQ.

We hope the information provided helps you resolve any issues with code repositories on the Apsara Devops platform. If you have any other questions or need further assistance, please feel free to contact us.