Short answer: Navigate to cPanel Git Version Control, click 'Create', input Clone URL from GitHub/GitLab, define target destination repository path, and deploy code effortlessly.
Deploy websites directly from GitHub, GitLab, or Bitbucket to your cPanel hosting using automated Git version control and .cpanel.yml deployment scripts.
Before you start: Back up your site files and database and download the backup to your own computer. How to take a full backup
Quick reference
| Tool Location | cPanel > Files > Git Version Control |
|---|---|
| Deployment Config File | .cpanel.yml (in repository root) |
| Supported Remote Hosts | GitHub, GitLab, Bitbucket, Private Git servers |
Steps
- Open Git Version Control: In cPanel, go to Files > Git Version Control.
- Create or Clone Repository: Click Create:
- Toggle Clone a Repository ON.
- Clone URL: Paste your GitHub or GitLab repository URL (HTTPS or SSH format).
- Repository Path: Provide a path outside
public_html(e.g.,/home/user/repositories/my-app) to prevent exposing your.gitmetadata directory. - Repository Name: Give it a descriptive identifier.
- Click Create.
- Create Deployment File (.cpanel.yml): In your repository's root directory, create a file named
.cpanel.ymlwith the following syntax:--- deployment: tasks: - export DEPLOYPATH=/home/YOUR_CPANEL_USER/public_html/ - /bin/cp -R * $DEPLOYPATH - Deploy Code: In cPanel Git Version Control, click Manage next to your repository, switch to the Deploy HEAD tab, and click Deploy HEAD Commit.
Deploy Git Repository via Server Terminal
# Clone the repository into the website folder
git clone git@github.com:USER/REPO.git ~/public_html
# Pull the latest changes and update the code
cd ~/public_html && git pull origin main
Troubleshooting and tips
- Authentication Failed for Private Repos: If cloning a private repo via SSH, go to cPanel > SSH Access, generate an SSH key pair without a passphrase, copy the public key, and add it to your GitHub repository under Settings > Deploy Keys.
- Changes not showing after push: Remember to pull changes in cPanel by clicking Pull or Deploy > Update from Remote before triggering Deploy HEAD Commit.
Need more help? If you run into an error while following these steps, open a ticket with technical support and our team will look into it. Open a ticket