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:
- In cPanel, go to Security → SSH Access → Manage SSH Keys
- Click Generate a New Key
- Leave the default settings and click Generate Key
- Go back to the list of keys, find the public key and click Manage → Authorize
- 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 #
- In cPanel, go to Files → Git™ Version Control
- Click Create
- Turn on the Clone a Repository option
- 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
- For a public repo:
- Under Repository Path, choose a folder — e.g.
/home/username/repositories/myproject - Enter a name for the repository under Repository Name
- 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/orbuild/ - 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:
- In cPanel, go to Git™ Version Control
- Find your repository and click Manage
- Click Update from Remote → Update
- 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:
- On your repository's page in cPanel, find the Pull URL — this is the URL that triggers a pull
- Copy that URL
- On GitHub, go to Settings → Webhooks → Add webhook
- Paste the Pull URL into the Payload URL field
- Content type:
application/json - 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.ymlwith smaller changes before you set up the webhook - Use a
branchstrategy — deploy only from themainorproductionbranch - 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.