Updated on 2023-07-25 GMT+08:00

Creating an Empty Repository

You can create an empty repository in the cloud and synchronize a local repository to that repository. To create an empty repository on the CodeHub console, perform the following steps:

  1. Access the repository list page.
  2. Click Create Directly. On the page that is displayed, enter basic repository information.

    Table 1 Parameters for creating an empty repository

    Parameter

    Mandatory

    Remarks

    Repository name

    Yes

    A name contains letters, digits, underscores (_), periods (.), and hyphens (-) and must start with a letter, digit, or underscore (_).

    Project

    Yes

    • A repository must be in a project.
    • If you create a repository in a project, the project is selected for Project by default, and the Project parameter is hidden on the repository creation page.

    Description

    No

    Enter the description of your repository.

    Programming Language of .gitignore

    No

    The .gitignore file is generated based on your selection.

    Type

    No

    Select a type for your repository content.

    Permissions

    No

    The options are as follows:

    • Allow project members to access the repository.

      The project manager is automatically set as the repository administrator, and the developer is set as a common repository member. When the two roles are added to the project, they will be automatically synchronized to existing repositories.

    • Allow generation of a README file.

      You can edit the README file to record information such as the project architecture and compilation purpose, which is similar to a comment on the entire repository.

    • Allow automated creation of a code check task.

      After the repository is created, you can view the code check task of the repository in the CodeCheck task list after switching to the region where the repository is located.

    Visibility

    Yes

    The options are as follows:

    • Private

      The repository is visible only to repository members. Repository members can access the repository or commit code.

    • Public read-only

      The repository is open and read-only to all guests, but is not displayed in their repository list or search results. You can select an open-source license as the remarks.

  3. Click OK to create the repository. The repository list page is displayed.

Associating with an Existing Directory or Repository

If you do not generate a README File when creating a common repository, you can click the Files tab and click Create a README file to generate a README file or associate the repository with an existing directory or repository. The procedure is as follows:

Figure 1 Associating with an existing directory or repository

Prerequisite

  • You need to run following commands on the Git client. Install the Git client and configure the Git global username and user email address. For details, see Git Installation and Configuration.
  • Set the SSH key. For details, see SSH Keys.

Procedure

The following commands have been automatically generated in the new repository. You can copy them on the Files tab page of the repository.

  1. Clone the repository on the local host and push the new README file.

    git clone HTTP_download_address
    cd taskecho "# Repository_name" > README.md.
    git add README.md
    git commit -m "add README"
    git push -u origin master

  2. Associate an existing code directory with the repository.

    cd <Your directory path>
    mv README.md README-backup.md
    git init
    git remote add origin  HTTP_download_address
    git pull origin master
    git add --all
    git commit -m "Initial commit"
    git push -u origin master

  3. Associate with an existing Git repository.

    cd <Your Git repository path>
    git remote remove origin > /dev/null 2>&1
    git remote add origin  HTTP_download_address
    git push -u origin --all -f
    git push -u origin --tags -f