Git deployment on cPanel hosting: clone a GitHub repository and publish it with .cpanel.yml

Print
  • 0

In short: cPanel can keep a copy of your GitHub project and push its files to the live site whenever you ask. The tool is called Git Version Control and sits among the Files tools. A small .cpanel.yml file tells it what to copy, and SSH access to the hosting is not required.

Many developers keep their code on GitHub and still upload changes by hand through FTP or File Manager. That works, but it is slow and easy to get wrong. With Git in cPanel, the code on GitHub becomes the single source, and an update of the site takes two clicks.

Before you start

How the process works

cPanel never clones straight into the website. It keeps the project in a separate folder of your account, for example repositories/site. When you deploy, it reads .cpanel.yml from that copy and runs the commands written there. Those commands put the chosen files into public_html. So there are two places: the repository copy, which only Git touches, and the site folder, which visitors see.

Prepare .cpanel.yml

Create this file at the top level of the repository, commit it and push it to GitHub:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/USERNAME/public_html/
    - /bin/cp -a public/. $DEPLOYPATH

Put your own cPanel username in place of USERNAME. If your site lives in a folder with another name, change public to that name. Indent the lines with spaces only; a tab breaks the file. Keeping the site in its own folder also means that .git, .cpanel.yml and any private notes stay out of public_html.

Add the repository to cPanel

  1. Sign in to cPanel and find Git Version Control under Files. Not in your panel? Send us a ticket and we will look at your account.
  2. Press Create, keep Clone a Repository switched on and paste the GitHub address into Clone URL, for example https://github.com/username/site.git.
  3. Set Repository Path to an empty folder outside the site, such as repositories/site, type any Repository Name and press Create.

A small project of a few MB is copied in seconds.

Put changes live

Each time you have pushed new work to GitHub:

  1. Go back to Git Version Control, press Manage on your repository and switch to the Pull or Deploy tab.
  2. Press Update from Remote. cPanel fetches the newest commits from GitHub.
  3. Press Deploy HEAD Commit. The commands from .cpanel.yml run and the site gets the new files.

Nothing happens on its own between these clicks. If you prefer the site to follow every push automatically, see How to deploy a website from GitHub automatically: GitHub Actions with FTPS on hosting or rsync on a VPS.

Pick the method that fits your project

Your projectRecommended way
Open-source or public repositoryClone over HTTPS, exactly as in this guide
Private repositoryA GitHub deploy key with read-only rights, then the same steps
You want hands-free updates on each pushA GitHub Actions workflow that uploads over FTPS
The site needs an npm build step (React, Vue, Astro)Run the build in GitHub Actions or locally and upload only the output

Troubleshooting a failed deploy

What you seeWhat to check
The deploy button does nothing or the files never arriveIs .cpanel.yml at the top level of the repository? Is it indented with spaces rather than tabs?
cPanel refuses to deploySomeone edited files inside repositories/site. Only a clean copy can be deployed, so make edits on GitHub or on your computer.
Files land in the wrong place or nowhereLook at DEPLOYPATH: the username must match your account and the folder must exist.

Good to know

  • SSH is optional. All three actions (clone, update, deploy) run from the cPanel interface. A shell only helps if you like using Git commands.
  • Old files stay. The cp command adds and replaces files but never removes them. Clean up leftovers in File Manager.
  • Keep public_html out of it. cPanel needs an empty target folder, and a clone there would expose the .git folder to visitors.
  • No secrets on GitHub. Database passwords and API keys must not be committed, even to a private repository. Protecting API keys in cPanel apps and WordPress: safe storage and leak response shows where to keep them.

Useful articles

Was this answer helpful?

Need help?

Write to us in the chat, by e-mail or open a ticket from your account.

Live chatOpen the chat Call us+373 795-800-80 Write to ussupport@tophost.md
Copyright © 2026 TopHost.MD. All Rights Reserved.