If you're used to a Git workflow — pushing code to GitHub or GitLab and deploying automatically — here's the good news: cPanel has built-in Git Version Control that lets you clone a repo straight onto your hosting and pull in changes with a single click or automatically.

What you need #

  • A Git repository on GitHub, GitLab or Bitbucket
  • Access to cPanel
  • If the repo is private — an SSH key or an access token

Step 1: Generate an SSH key (for private repositories) #

If your repo is public, skip this step. For private repositories:

  1. In cPanel, go to Security → SSH Access → Manage SSH Keys
  2. Click Generate a New Key
  3. Leave the default settings and click Generate Key
  4. Go back to the list of keys, find the public key and click Manage → Authorize
  5. Copy the contents of the public key and add it to your GitHub/GitLab profile under Settings → SSH Keys

Step 2: Clone the repository in cPanel #

  1. In cPanel, go to Files → Git™ Version Control
  2. Click Create
  3. Turn on the Clone a Repository option
  4. In the Clone URL field, enter your repository's URL:
    • For a public repo: https://github.com/korisnik/projekt.git
    • For a private repo (SSH): git@github.com:korisnik/projekt.git
  5. Under Repository Path, choose a folder — e.g. /home/username/repositories/myproject
  6. Enter a name for the repository under Repository Name
  7. Click Create

Important: the Repository Path must NOT be public_html itself. Clone into a separate folder and use .cpanel.yml to define what gets copied to public_html.

Step 3: Set up deployment with .cpanel.yml #

Create a .cpanel.yml file in the root directory of your repository. This file tells cPanel what to do once new code has been pulled:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/username/public_html/
    - /bin/cp -R dist/* $DEPLOYPATH

This example copies the contents of the dist/ folder to public_html. Adjust the paths to suit your project:

  • Static sites: copy all the files
  • React/Vite build: copy the contents of dist/ or build/
  • PHP projects: copy the whole project or only the relevant files

Step 4: Pull the changes #

When you've made changes to your code and pushed them to GitHub:

  1. In cPanel, go to Git™ Version Control
  2. Find your repository and click Manage
  3. Click Update from Remote → Update
  4. cPanel will pull the latest code and run the deployment as defined in .cpanel.yml

Automatic deployment via a webhook #

If you want deployment to run automatically after every push:

  1. On your repository's page in cPanel, find the Pull URL — this is the URL that triggers a pull
  2. Copy that URL
  3. On GitHub, go to Settings → Webhooks → Add webhook
  4. Paste the Pull URL into the Payload URL field
  5. Content type: application/json
  6. Click Add webhook

From now on, every push to GitHub automatically triggers a deployment to your hosting. This is especially useful if you use tools such as Lovable or Bolt that push code to GitHub — your website on the hosting is updated automatically.

Practical tips #

  • Always test .cpanel.yml with smaller changes before you set up the webhook
  • Use a branch strategy — deploy only from the main or production branch
  • If your project needs npm build, you can run the build locally, in a CI/CD pipeline or on the hosting, in the Setup Node.js App tool (Run JS script → build). How to run a Node.js application on the hosting is described in the guide to Node.js in cPanel.

Need help setting up Git deployment? Get in touch at info@wmd.hr or via live chat — we're here 24/7.