How to use Git version control in cPanel to install and update a site

Git is a distributed version control system used by many programmers. The cPanel Git Version Control tool provides a convenient graphical interface that allows access to Git features without using the command line.

You can use this tool to install and update a web site stored in a Git repository. This article shows how to install a simple 'Hello World!' example. You can follow the same steps to install an application of any size.

This article also shows how to clone a private Git repository.

Installing the site

In this example, a developer has created a web page and placed it in a repository on Github. To install the site from the Git repository, follow these steps:

  1. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  2. Open the Git Version Control tool:
    • If you are using the Jupiter theme, on the Tools page, in the Files section, click Git Version Control:

      cPanel - Files - Git Version Control icon

    • If you are using the Paper Lantern theme, in the FILES section of the cPanel home page, click Git Version Control:

      cPanel - Files - Git Version Control icon

  3. On the Git Version Control page, click Create:

  4. On the Create Repository page, confirm that the Clone a Repository slider is enabled.
  5. In the Clone URL text box, type the URL of the repository to clone. In this example, the site is being cloned from GitHub:

  6. In the Repository Path text box, type the path to the document root of the site:

    Typically, the document root directory is public_html. However, you can install the site in a subdirectory beneath public_html if you want. If you do this, make sure you set the correct permissions for the directory so the site is visible. For information about how to set file permissions, please see this article.
  7. In the Repository Name text box, type a descriptive name for your repository:

  8. Click Create:

    In the document root directory there is now the index.html file containing the 'Hello World!' message and a .git directory that contains files used by Git:

    The .git directory is not visible to site visitors by default.

Updating the site

The site developer has created an 'About' page to supplement the 'Hello World!' message, and has added it to the Github repository. To update the site, follow these steps:

  1. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  2. Open the Git Version Control tool:
    • If you are using the Jupiter theme, on the Tools page, in the Files section, click Git Version Control:

      cPanel - Files - Git Version Control icon

    • If you are using the Paper Lantern theme, in the FILES section of the cPanel home page, click Git Version Control:

      cPanel - Files - Git Version Control icon

  3. Locate the hello-world repository, and then click Manage:

  4. Click the Pull or Deploy tab:

  5. Click Update from Remote:

    The new about.html page is now in the document root directory:

Cloning a private repository

For public repositories, the previous procedures work as expected. However, if you try to clone a private repository using the procedure above, you receive an error message that resembles the following:

Error: (XID xna4yx) “/usr/local/cpanel/3rdparty/bin/git” reported error code “128” when it ended: fatal: could not read Username for 'https://github.com': No such device or address

To clone a private repository, you must use an SSH key pair and the SSH protocol in the clone URL. To do this, follow these steps:

  1. At the command line on your A2 Hosting account, if you have not already done so, create an SSH key pair:
    ssh-keygen -t rsa
  2. View the text of the public key:

    cat ~/.ssh/id_rsa.pub
  3. Copy the text of the public key you obtained in step 2.
  4. Add the SSH public key text to the Git provider you are using:

  5. At the command line on your account, type one of the following commands to test the connection to the Git provider:

  6. After you verify that the SSH connection is working, you are ready to clone the private repository using the ssh:// protocol. In cPanel, follow these steps:

    • Open the Git Version Control tool:
      • If you are using the Jupiter theme, on the Tools page, in the Files section, click Git Version Control:

        cPanel - Files - Git Version Control icon

      • If you are using the Paper Lantern theme, in the FILES section of the cPanel home page, click Git Version Control:

        cPanel - Files - Git Version Control icon

    • On the Git Version Control page, click Create:

    • On the Create Repository page, confirm that the Clone a Repository slider is enabled.
    • In the Clone URL text box, type the URL of the repository to clone, using the ssh:// protocol. For example, to clone a private GitHub repository you would type ssh://[email protected]/username/repository.git, where username represents your GitHub username, and repository represents the name of the repository you want to clone.
    • In the Repository Path text box, type the path to the document root of the site:

      Typically, the document root directory is public_html. However, you can install the site in a subdirectory beneath public_html if you want. If you do this, make sure you set the correct permissions for the directory so the site is visible. For information about how to set file permissions, please see this article.
    • In the Repository Name text box, type a descriptive name for your repository:

    • Click Create:

      cPanel clones the private repository with the settings you specified. To update the repository, follow the steps in Updating the site above.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.