Help Center/ CodeArts Repo/ User Guide/ Old Version/ Committing Code to the Cloud/ Pushing Code to CodeHub Using Eclipse
Updated on 2023-07-25 GMT+08:00

Pushing Code to CodeHub Using Eclipse

Background

You can install EGit on Eclipse so that Eclipse can be connected with CodeHub and be used for operations such as committing code from a local Git repository to a remote one.

Only Eclipse 4.4 or later versions are supported.

  • For the first push:
    1. Create a repository on the local computer, that is, the local repository.
    2. Commit the update to the local repository.
    3. Pull the code from the server to the local repository, merge the code, and push the repository to the server.
  • If it is not the first push:
    1. Commit the modified code to the local repository.
    2. Pull the code from the server to the local repository, merge the code, and push the repository to the server.

Step 1: Installing EGit on Eclipse

Eclipse 4.4 is used in the following procedure.

  1. On the Eclipse toolbar, choose Help > Install New Software....

  2. In the Install window displayed, click Add....

  3. Click OK. Then, click Next until the installation is finished.

    Restart Eclipse after the installation.

Step 2: Configuring EGit on Eclipse

  1. On the Eclipse toolbar, choose Window > Preferences > Team > Git > Configuration.

    Set Key to a registered username.

  2. Click OK.

    user.email indicates the bound email address. If the user.name is not set previously, set it in this step.

Step 3: Creating a Project and Committing Code to the Local Git Repository

  1. Create the git_demo project and the HelloWorld.java class.

  2. Share the git_demo project with the local repository.

  3. In the Share Project window displayed, select Git.

  4. Click Next. The Configure Git Repository dialog box is displayed.

  5. Click Create Repository to create a Git repository.

    The directory is in the untracked status, indicated by a question mark (?).

    Choose Team > Commit... to commit code to the local repository.

  6. In the Commit Changes dialog box displayed, set the commit message.

  7. Click Commit to commit the code to the local repository.

Step 4: Committing Code in the Local Repository to the Remote Git Repository

  1. Create a repository in CodeHub.

    Go to the repository details page and copy the repository URL.

  2. Choose Team > Remote > Push... to push the code to the remote repository.

  3. Set related parameters in the Push to Another Repository window.
  4. Click Next. The Push Ref Specifications dialog box is displayed.

  5. Click Add Spec.

  6. Click Next. The Push Confirmation dialog box is displayed.

  7. Click Finish.

  8. Click OK.

    Log in to the remote repository and check the submitted code.