cPanel has introduced the long-awaited feature(hurray!) in their version 72 which is a boon for the developers out there who are using cPanel in their production environment. I am taking the liberty of assuming that you are familiar with the Git and it’s use cases since you have clicked this link on purpose :). So let’s get started on Git version control in Cpanel.

For those who came here out of pure curiosity, please go through the below mentioned Git 101.

“Git is a version control software. Whenever Git-managed content is changed, Git records it and stores the history of every change you’ve made.”

So let’s get started. Before proceeding to implement the following steps just make sure the following prerequisites:

  • Cpanel version 72 server (shared,VPS,dedicated anything will do)
  • Shell access to the server.

The first step is to create a repo on the cpanel account where we are going to store the project files.

Step 1 : Login to cPanel(obviously) Go to Git version control under Files section.

Step 2: Click on create button

Step 3: You can either clone an already existing repo or create a new one.(Here I am going to create a new one.If you want to continue with creating an new one ,don’t forget to toggle the Clone a Repository switch).

Fill in the Repository Path and Repository Name with the required details and click create. Here I am using the name test for both input fields.You will be directed to a getting started page where you will find the required instruction suitable for both an existing repo and new ones.

To access this newly created repo from the local computer you are using,install the following git client from the link given below:

The installation can be customized based on your personal preference and the description of each options are given right below them which makes the installation hassle free.

After the installation, open the git bash or command prompt (which ever you selected during the installation) and execute the below mentioned command to clone the remote repo (in this case our cPanel managed repo) to your local computer.

git clone ssh://

This will clone the repo hosted in the cPanel server to the PWD (present working directory).

Now everything else will work as same as normal git operation.

Let’s look into some basic commands to refresh your memory.

To create a branch;

git checkout -b [branch name]

To select a specific branch for working;

git checkout [branch name]

To add a file or change in file;

git add [filename]

To add everything in a specific directory or location;

git add *

To commit those changes;

git commit -m [commit message]

To save changes made;

git push origin master

To view the recent activity;

git log

To display last author that modified a line;

git blame [file name]

Most of these changes made can be tracked in a more detailed manner through the front end provided by the cPanel. For this you need to select the repo that you want to check and click history. There you will get a comprehensive list of search options in the top left side where you can search the entire branch for specific change based on the commit, author ,committer and the general purpose grep. Selecting a specific commit will show its options to check the difference in commits (commitdiff). Log lists the relevant log details.Tree option will show the contents of that repo. Snapshot will let you download that specific version to your local machine in tar.gz format.

Now comes the most interesting part. As a part of continuous integration the developer can instantly deploy the code he/she wrote into the production environment.

Just consider a scenario where the developer is making changes to the index file as an example. The changes made to that file can be selectively (the best version can be decided as same file has various versions) deployed in the public_html directory. There are 2 ways of deployment – Manual and Automated (pull or push method in git language).
Manual method or Pull deployment, pulls changes from a remote repository to the local computer and pushes new changes from the local computer to the remote repository. You can then use the Git Version Control interface ( cPanel >> Home >> Files >> Git Version Control>>Repo>>Manage>>Pull or Deploy ) to manually deploy changes that you pull from the remote repository.

While Automatic or Push deployment first pulls changes from a remote repository to the local computer. Then, they are pushed to the cPanel-managed repository. The system will automatically deploy changes that are being pushed to the cPanel-managed repository. Now, what if I need to make a manual change to a single file? Manual deployment mode comes to help then.

In manual deployment whichever branch you want the deployment to happen from should contain a .cpanel.yml file which basically tells what and where the contents residing in that specific branch should be copied(deployed) to. A sample of the content of a typical .cpanel.yml file is given below:

- export DEPLOYPATH=/home/user/public_html/
- /bin/cp home.html $DEPLOYPATH
- /bin/cp style.css $DEPLOYPATH

As soon as we click the “Deploy HEAD commit button under Pull or Deploy section, it will copy the data from that branch to the “DEPLOY PATH”.
Cool isn’t it?

I hope you learned something useful from this write-up. It’s all about Push and Pulls!

Do you need any expert advice on Git version control in Cpanel?

We have an expert team to guide you

Thanks for dropping by. Ready for the next blog?

Optimize MySQL server performance using MySQLTuner

Prem Prakash
Author : Prem Prakash
Written on : 29 Oct, 2018

Who we are ?

Founded in 2010, we are a team of a sysadmins with super awesome server management skills who likes to give super quality support at super affordable price.