Git Version Control
The Git Version Control feature in cPanel lets you host Git repositories directly on your account. Track changes to your code, pull from an external remote such as GitHub, and deploy new versions to your site automatically.
Opening Git Version Control
- Log into cPanel.
- In the Files section, click Git Version Control.
- The page lists any repositories already on your account and offers a Create button to add a new one.
public_html and deploy into the web root, so your .git folder and any development files are never served to the public.
Creating a New Repository
To start a brand-new repository on the server:
- Click Create on the Git Version Control page.
- Leave Clone a Repository toggled off.
- Enter the Repository Path where the repo should live, for example
repositories/mysite. - Give the repository a Name for the cPanel listing.
- Click Create. cPanel initialises an empty repository you can start pushing to.
Cloning an Existing Remote
To pull in a repository that already exists on GitHub, GitLab, Bitbucket, or another host:
- Click Create, then toggle Clone a Repository on.
- Enter the Clone URL. For private repositories use the SSH form, for example
[email protected]:youruser/yourrepo.git. - Set the Repository Path and Name.
- Click Create to clone the remote onto your account.
Working over SSH
Once a repository exists on the server, you can drive it from an SSH session just like on your own machine. Connect over SSH (see SSH Access), change into the repo, and use the normal Git commands:
cd ~/repositories/mysite
git clone [email protected]:youruser/yourrepo.git
git status
git add .
git commit -m "Update homepage copy"
git push origin main
git pull origin main
Configure your identity once per account so commits are attributed correctly:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Automatic Deployment with .cpanel.yml
cPanel can deploy your repository automatically. Add a file named .cpanel.yml to the root of the repository. It defines the tasks to run each time you deploy — typically copying files from the repo into public_html:
---
deployment:
tasks:
- export DEPLOYPATH=/home/cpuser/public_html/
- /bin/cp -R index.html $DEPLOYPATH
- /bin/cp -R assets/ $DEPLOYPATH
- /bin/cp -R includes/ $DEPLOYPATH
Replace cpuser with your own cPanel username. Commit and push the .cpanel.yml file, then trigger a deployment either from the Manage screen of the repository in cPanel (the Pull or Deploy tab) or from the command line:
cd ~/repositories/mysite
git pull
/usr/local/cpanel/3rdparty/bin/git-deploy
.cpanel.yml tasks and always list the exact files and folders you want copied to avoid overwriting anything unexpected in public_html.
Getting Help
If a clone fails with an authentication error, a push is rejected, or a deployment does not update your site, double-check the SSH key on the remote and the paths in your .cpanel.yml. If you are still stuck, open a support ticket with the repository name and the exact error message.