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

Uploading Local Code to CodeHub

Background

CodeHub allows you to perform Git initialization on local code and upload the code to a CodeHub repository.

Procedure

  1. Create an empty repository in CodeHub.

    • Do not configure Programming Language of .gitignore.
    • Deselect Allow generation of a README file.

  2. Prepare the source code to be uploaded on the local host.

    • If the source code is from the SVN server, refer to Migrating an SVN Repository to CodeHub.
    • If the source code is not managed by any version control systems, run the following Git command in the root directory of the source code (Git Bash is used as an example):
      1. Initialize a Git repository:
        git init

      2. Add the code files to the local repository:
        git add *
      3. Create an initial commit:
        git commit -m "init commit"

  3. Set a remote server address for the local repository.

    • If the Git repository is cloned from other systems, run the following command to add a new remote repository:
      git remote add new git@***.***.com:testtransfer/Repo1.git      # (replace the part after new with the repository address)

      The repository address is displayed on the repository details page. The following figure shows how to obtain the repository address.

    • If the Git repository is just initialized, run the following command to add a remote repository named origin.
      git remote add origin git@***.***.com:testtransfer/Repo1.git # (replace the part after origin with the repository address)

  4. Push all code to the remote repository.

    git push new master      # (when the Git repository is cloned from other systems)
    git push origin master   # (when the Git repository is just initialized)