> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Git version control in cPanel to install and update a site

> Discover how to use Git in cPanel to install and update sites from public and private repositories.

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.
   > 📘 Note
   >
   > If you do not know how to log in to your cPanel account, please see [this article](/docs/accessing-cpanel).

2. On the **Tools** page, in the **Files** section, click **Git Version Control**:\
   ![](https://static.hosting.com/kb/kb-cpanel-jupiter-git-version-control-icon.png)

3. On the **Git Version Control** page, click **Create**:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-create-button.png)

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:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-create-form-clone.png)

6. In the **Repository Path** text box, type the path to the document root of the site:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-create-form-path.png)

   > 👍 Tip
   >
   > 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](/docs/file-permissions).

7. In the **Repository Name** text box, type a descriptive name for your repository:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-create-form-name.png)

8. Click **Create**:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-create-button.png)

   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:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-folder-contents1.png)

   > 📘 Note
   >
   > 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.
   > 📘 Note
   >
   > If you do not know how to log in to your cPanel account, please see [this article](/docs/accessing-cpanel).

2. On the **Tools** page, in the **Files** section, click **Git Version Control**:\
   ![](https://static.hosting.com/kb/kb-cpanel-jupiter-git-version-control-icon.png)

3. Locate the **hello-world** repository, and then click **Manage**:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-manage.png)

4. Click the **Pull or Deploy** tab:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-pullordeploy-tab.png)

5. Click **Update from Remote**:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-updatefromremote-button.png)

   The new *about.html* page is now in the document root directory:\
   ![](https://static.hosting.com/kb/kb-cpanel-git-folder-contents2.png)

## 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 hosting.com account, if you have not already done so, create an SSH key pair:

   ```bash theme={null}
   ssh-keygen -t rsa
   ```

2. View the text of the public key:

   ```bash theme={null}
   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:

   * For information about how to add an SSH key in GitHub, please visit [https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).

   * For information about how to add an SSH key in GitLab, please visit [https://docs.gitlab.com/ee/ssh](https://docs.gitlab.com/ee/ssh).

   * For information about how to add an SSH key in Bitbucket, please visit [https://confluence.atlassian.com/bitbucketserver/enable-ssh-access-to-git-repositories-776640358.html](https://confluence.atlassian.com/bitbucketserver/enable-ssh-access-to-git-repositories-776640358.html).

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

   * For GitHub, type the following command:

     ```bash theme={null}
     ssh -vT git@github.com
     ```

   * For GitLab, type the following command:

     ```bash theme={null}
     ssh -vT git@gitlab.com
     ```

   * For Bitbucket, type the following command:

     ```bash theme={null}
     ssh -vT git@bitbucket.org
     ```

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:

   * On the **Tools** page, in the **Files** section, click **Git Version Control**:\
     ![](https://static.hosting.com/kb/kb-cpanel-jupiter-git-version-control-icon.png)

   * On the **Git Version Control** page, click **Create:**\
     ![](https://static.hosting.com/kb/kb-cpanel-git-create-button.png)

   * 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://git@github.com/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:\
     ![](https://static.hosting.com/kb/kb-cpanel-git-create-form-path.png)

     > 👍 Tip
     >
     > 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](/docs/file-permissions).

   * In the **Repository Name** text box, type a descriptive name for your repository:\
     ![](https://static.hosting.com/kb/kb-cpanel-git-create-form-name.png)

   * Click **Create**:\
     ![](https://static.hosting.com/kb/kb-cpanel-git-create-button.png)

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

## Related articles

* [Using Git](/docs/using-git)

* [Using Git with Plesk](/docs/using-git-with-plesk)
