cPanel’s Git Version Control tool, in the Files section, can deploy a WordPress theme or plugin straight from a Git repository, which takes the FTP upload out of your release routine. It keeps a normal Git clone inside the hosting account. When the checked-out branch has a file named .cpanel.yml at its root, cPanel runs the shell commands in that file as the account’s user. Those commands are a short list of copy steps that move your theme or plugin folder from the clone into wp-content/themes/ or wp-content/plugins/. Keep the repository to a single theme or plugin and get the YAML format right, and the FTP step goes away. Get either one wrong and the Deploy button does nothing, with no visible error.
What you’ll accomplish
- A Git repository living inside the cPanel account, either cloned from GitHub/GitLab or pushed to directly over SSH from a developer laptop.
- A
.cpanel.ymlat the repository root that copies exactly one theme or plugin directory into place — and nothing else. - SSH keys wired in the correct direction for whichever of the two setups you picked.
- A deployment you can trigger from the cPanel interface or from the account’s shell, with a check that tells you which commit is currently live.
- A rollback path, plus a build-artifact strategy for themes that need a compile step cPanel cannot run.
Prerequisites
- cPanel & WHM with Git Version Control enabled. The feature arrived in the cPanel 7x series and gained
.cpanel.ymldeployment shortly afterwards; anything current is fine. If the tile is missing from the Files section, the hosting provider has disabled it in the feature list and only they can turn it back on. - SSH access on the account. Git Version Control’s own clone/pull operations work without it, but you cannot push to a repository in the account, inspect a deployment, or fix a detached HEAD without a shell. Shell access is granted per account in WHM; on shared plans you may need to ask.
- Git 2.x on the server and on the laptop. cPanel servers ship a system Git; you do not install your own.
- A repository that contains one theme or one plugin at its root —
style.cssandfunctions.phpsitting at the top level, not nested underwp-content/themes/. That single decision removes most of the pain later. - Assumptions in the commands below: cPanel user
acmeuser, document root/home/acmeuser/public_html, theme directoryacme-theme, deployment branchmain.
How it works
cPanel creates the repository under the account’s home directory — by default ~/repositories/<name>, and it is a normal clone with a working tree, not a bare repository. Whatever branch is checked out in that clone is the branch cPanel considers deployable.
When a deployment runs, cPanel reads .cpanel.yml from the root of that checked-out branch, takes the list under deployment: tasks:, and executes those lines in order as the cPanel user, with the repository’s working directory as the starting point. The tasks share one shell environment, which is why the canonical example exports a variable in one task and uses it in the next. If a task exits non-zero, the deployment stops there.
Two structural facts follow from that, and both matter:
- The deployed files are a copy.
public_htmlis never a Git checkout. Nothing in the document root is under version control, so no.gitdirectory is ever exposed to the web — a real advantage over the “justgit pullinto the docroot” pattern. - cPanel is not a CI runner. The task list is a plain shell sequence with a minimal environment. There is no dependency cache, no build image, and on jailed shells frequently no
npmorcomposeronPATHat all.
The two setups differ only in where the authoritative repository lives:
- Clone a remote repository into the account. GitHub or GitLab stays the source of truth. cPanel pulls from it. The key direction: the cPanel account holds a private key, and its public half goes on the remote as a read-only deploy key. Read-only is correct — the server never pushes.
- Create a repository in the account and push to it over SSH. cPanel is the remote. The key direction reverses: each developer’s public key is authorised on the cPanel account. This is the setup where a push can deploy on its own, because the push lands directly on the repository cPanel is watching.
Step-by-step
1. Confirm shell access and Git on the account. Non-standard SSH ports are common on cPanel hosts; check the provider’s welcome message.
ssh -p 22 acmeuser@server.example.com 'git --version; echo shell-ok'
Expect a version line such as git version 2.39.x followed by shell-ok. A password prompt loop or This account is currently not available means shell access is off and you should stop here.
2. Set up the key in the direction your setup needs. For the clone-from-GitHub setup, generate the key on the cPanel account, with no passphrase — an interactive prompt during a background deployment would simply hang.
ssh-keygen -t ed25519 -C "cpanel-acmeuser-deploy" -f ~/.ssh/id_ed25519_deploy -N ""
cat ~/.ssh/id_ed25519_deploy.pub
Paste that public key into the repository’s deploy keys on GitHub or GitLab and leave write access unchecked. Then pin the key and accept the host fingerprint once:
printf 'Host github.com\n IdentityFile ~/.ssh/id_ed25519_deploy\n IdentitiesOnly yes\n' >> ~/.ssh/config
chmod 600 ~/.ssh/config
ssh -T git@github.com
Success looks like a greeting naming the repository and stating that shell access is not provided. Anything ending in Permission denied (publickey) means the deploy key was not saved or the wrong key was pasted. For the push-to-cPanel setup instead, import each developer’s public key through cPanel’s SSH Access interface and authorise it there — do not paste private keys into the panel.
3. Write .cpanel.yml at the repository root. In your local clone, at the top level, next to style.css:
---
deployment:
tasks:
- export THEME=/home/acmeuser/public_html/wp-content/themes/acme-theme
- /bin/mkdir -p $THEME
- /bin/cp -R ./ $THEME/
The rules that break deployments, in the order people hit them: the file must be named exactly .cpanel.yml; it must live at the repository root, not in a subfolder; it must exist on the branch that is checked out on the server, so a .cpanel.yml merged only into develop while main is deployed does nothing; indentation must be spaces, never tabs; and commands should use absolute paths because the deployment environment’s PATH is minimal.
If rsync is present — check with command -v rsync on the account — prefer it, because it removes files you deleted in Git instead of leaving orphans behind:
---
deployment:
tasks:
- export THEME=/home/acmeuser/public_html/wp-content/themes/acme-theme
- /bin/mkdir -p $THEME
- /usr/bin/rsync -a --delete --exclude '.git' --exclude '.cpanel.yml' ./ $THEME/
That --delete is only safe because the repository contains one theme and the destination is that theme’s directory. Never point a --delete task at public_html.
4. Decide what the repository is allowed to touch. This is the step that separates a deployment from an outage. Uploads, wp-config.php, and WordPress core are runtime state, not source; they belong to the site, not the repo.
5. Commit, push, and connect the repository. Push the deployment file to the branch you intend to deploy:
git add .cpanel.yml
git commit -m "Add cPanel deployment tasks"
git push origin main
Then in cPanel, open Git Version Control, create the repository — either supplying the remote clone URL, or creating an empty repository in the account and using the SSH clone URL it shows you as a Git remote from the laptop. Confirm from the shell:
git -C ~/repositories/acme-theme branch --show-current
git -C ~/repositories/acme-theme log --oneline -1
ls ~/repositories/acme-theme/.cpanel.yml
Expect main, a commit line matching what you just pushed, and the path echoed back. If ls reports no such file, the Deploy control will stay unavailable.
6. Deploy. In the repository’s management screen, the Pull or Deploy tab holds both actions: pulling updates from the remote and deploying the current HEAD commit. From the shell, the same queued deployment can be started with cPanel’s API:
uapi VersionControlDeployment create repository_root=/home/acmeuser/repositories/acme-theme
A successful call returns a JSON payload containing the queued deployment’s details. The deployment itself runs in the background, so the response arriving is not proof the copy finished — verify at the destination, next section.
7. Set permissions in the task list if the source modes are wrong. Files land owned by the cPanel user, which is what PHP runs as, so ownership is rarely the problem; modes copied from a laptop sometimes are. Append two tasks:
- /usr/bin/find $THEME -type d -exec /bin/chmod 755 {} +
- /usr/bin/find $THEME -type f -exec /bin/chmod 644 {} +
Validate it works
Compare the commit in the repository with the bytes actually serving the site:
git -C ~/repositories/acme-theme rev-parse --short HEAD
grep -m1 -i 'Version:' ~/public_html/wp-content/themes/acme-theme/style.css
ls -l ~/public_html/wp-content/themes/acme-theme/style.css
The theme header version should match the commit you deployed, and the timestamp on style.css should be seconds old. Then confirm WordPress itself agrees, and that no .git directory rode along:
cd ~/public_html && wp theme list --status=active --field=name
test -d ~/public_html/wp-content/themes/acme-theme/.git && echo LEAKED || echo clean
curl -s -o /dev/null -w '%{http_code}\n' https://example.com/wp-content/themes/acme-theme/style.css
Expect the theme name, clean, and 200.
Troubleshooting
The Deploy control is unavailable or greyed out. Three causes, in frequency order: no .cpanel.yml on the checked-out branch; the clone is in detached HEAD state so cPanel has no branch to deploy; or a deployment is already queued. Check the branch first with git -C ~/repositories/acme-theme status.
“Could not find the .cpanel.yml file” after you swear you committed it. You committed it to a different branch, or to a subdirectory. Verify against the deployed branch specifically:
git -C ~/repositories/acme-theme ls-tree --name-only main | grep cpanel
An empty result is the answer. Merge the file into main and push again.
The deployment reports success but nothing changed on the site. Almost always a wrong destination path in the task list — a typo in the theme folder name creates a new, unused directory rather than failing. Run ls -la ~/public_html/wp-content/themes/ and look for the near-miss folder. A cached page can also hide a correct deployment; purge the object and page cache before concluding.
Detached HEAD after a manual checkout on the server. People roll back by checking out an older commit directly in ~/repositories/, which disables deployment. Return to the branch, then roll back properly through Git history:
git -C ~/repositories/acme-theme checkout main
git revert --no-edit <bad-sha>
Push the revert from your working clone and redeploy. That is the honest rollback: a new commit that undoes the old one, deployed the same way as everything else. Checking out old commits on the server leaves you outside the mechanism.
The build never ran. cPanel executes your task list, not a build pipeline; jailed shells usually have neither npm nor composer on PATH, and even where they exist, a long install on a shared host is a poor idea. Build in CI, commit the compiled build/ or dist/ output to the deployment branch, and keep sources on a separate branch — or push a built artifact to a release branch that cPanel is the only consumer of. The Plesk equivalent does offer a build hook, which is one real difference between the two panels.
When this is the wrong approach
cPanel Git Version Control deploys files. It does not run database migrations, does not sync content, and has no concept of an environment beyond the account it lives in. If what you need is moving a whole tested site forward — content, options, plugin state — that is a promotion problem, covered in promoting WordPress changes from staging to production on cPanel and in the WP Toolkit staging workflow. The two coexist well: staging gets its own cPanel account with its own clone of the same repository on a staging branch and its own .cpanel.yml, so the same commit reaches both, in order.
Skip this feature entirely when the deliverable is a full-site codebase with Composer-managed dependencies, or when you need approvals, test gates, and multi-server fan-out. Those want a real CI system pushing to the host. And if the site is one theme edited twice a year, a deployment pipeline is more machinery than the problem deserves. cPanel’s own documentation for the feature lives at docs.cpanel.net, and Git’s reference for the plumbing commands above is at git-scm.com/docs.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.