Skip to Content
Shared hosting (cPanel)Using cPanelFiles and backups

Manage your code with Git Version Control

The Git™ Version Control tool in the Files section lets you link a folder on your hosting to a Git repository, so you can deploy site updates by pulling them from GitHub or GitLab instead of uploading files manually.

Clone an existing repository

Open Files → Git™ Version Control and click Create.

Leave Clone a Repository enabled and paste the repository URL into Clone URL. It must start with https://, ssh://, or git://, or use the [email protected]:user/repo.git format.

In Repository Path, enter the folder to clone into, relative to your home directory (such as repositories/my-site). If it doesn't exist, it's created.

Enter a Repository Name, which is for display only, then click Create.

The form for cloning a Git repository in cPanel

Private repositories

To clone a private repository, create an SSH key on your account (see SSH access), add its public key to the repository on GitHub or GitLab as a deploy key, then use the repository's SSH URL.

New repository

Disable Clone a Repository to create an empty repository in the folder you specify, then push to it from your computer over SSH.

Pull and deploy updates

In the list of repositories, click Manage next to the repository, then open the Pull or Deploy tab:

  • Update from Remote: pulls the latest changes from the remote repository.
  • Deploy HEAD Commit: runs the deployment commands written in the .cpanel.yml file at the root of the repository, such as copying files to public_html.

Here's an example .cpanel.yml that copies the site to its public folder:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/username/public_html/
    - /bin/cp -R * $DEPLOYPATH
Don't put the repository inside public_html

If the repository is inside the public folder, visitors may be able to reach the .git folder, which contains your code's full history. Keep the repository outside public_html and deploy from it with a .cpanel.yml file.

How is this guide?

On this page