cPanel includes built-in Git support, allowing you to create and manage Git repositories for version control of your website files. This is ideal for developers who want to deploy code changes through Git rather than FTP.
Please note: Screens and options may vary slightly depending on your cPanel version and hosting plan.⚠️ Caution: Incorrect changes here can make your website inaccessible. If you are unsure about any step, please contact our support team before proceeding.
Creating a Git Repository
- Log in to your cPanel account.
- In the Files section, click Git Version Control.
- Click Create.
- Choose whether to Clone a Repository (from an existing remote like GitHub/GitLab) or create an empty repository.
- If cloning, enter the Clone URL (e.g.
https://github.com/youruser/yourrepo.git). - Enter the Repository Path on the server (e.g.
/home/username/repositories/mysite). - Enter a Repository Name for identification.
- Click Create.
Deploying from a Remote Repository
A common workflow is to push code to GitHub or GitLab, then pull changes onto your server:
- Clone your remote repository into a directory on the server (not directly into
public_html). - Use the
.cpanel.ymldeployment file to specify how to deploy changes.
The .cpanel.yml File
Create a file called .cpanel.yml in the root of your repository:
---
deployment:
tasks:
- export DEPLOYPATH=/home/username/public_html/
- /bin/cp -R * $DEPLOYPATH
This copies all repository files to your public_html directory whenever you pull or push changes. Adjust the tasks to suit your deployment process (e.g. running a build script, excluding certain files, etc.).
Pulling Updates
- Go to Git Version Control in cPanel.
- Click Manage next to your repository.
- Click Pull or Deploy > Update from Remote.
Alternatively, via SSH:
cd /home/username/repositories/mysite
git pull origin main
Tips
- Keep your repository outside
public_htmlto avoid exposing.gitdirectories to the public. - Use
.gitignoreto exclude configuration files containing sensitive data (database passwords, API keys). - The
.cpanel.ymldeployment system runs automatically when changes are received viagit pushto the server. - For private repositories, you may need to configure SSH keys or use an access token in the clone URL.
What Next?
- Using SSH Access — Connect to your server for command-line Git operations.
- Using the In-Browser Terminal — Run Git commands from your browser.