How to Host Git Repositories on a cPanel Account

By on October 24th, 2018

How to Host Git Repositories on a cPanel Account

cPanel accounts can host Git repositories if have appropriate permissions. Git is an efficient open-source Version Control System(VCS).  It tracks contents such as files and directories. It manages changes to a project without overwriting any part of the project.


Functions of a VCS:

Allows developers to work simultaneously.

Does not allow overwriting each other’s changes.

Maintains a history of every version.


Two types of VCS are there: Centralized version control system (CVCS) and Distributed/Decentralized version control system (DVCS). Git is a Distributed Version Control System. It tracks files and directories of a system. It manages changes to a project without overwriting any part of the project. So multiple users can manage files simultaneously.


Advantages of Git are listed below:

Free and open source.

Fast and small.

Implicit backup.


No need for powerful hardware.

Easier branching.


Steps to host a Git repository on your cPanel Account:

Create a repository.

Follow the below steps to create a new repository:

1) SSH to your cPanel account through the command line.

2) Create a new directory to store your repository by running the following command:

mkdir -p ~/Project/example

3) Navigate to the newly-created directory by running the below command:

cd ~/Project/example

4) Run the below command to initialize the directory as a Git repository.

 git init


Update the repository’s Git configuration.

This is an optional step that configures the Git repository to remain up to date as you push changes from the local branch.

To update the configuration, run the following command from within the repository directory:

git config receive.denyCurrentBranch updateInstead


Clone the repository locally

To clone the cPanel-account-hosted repository, you need to access your local computer via the command line and run the following command:

git clone ssh://username@hostname:/home/username/Project/example.git

where: username represents the cPanel account username.

hostname represents the hostname for the server on which your cPanel account is hosted.


Clone an existing repository to your cPanel account.

If a Git repository already exists for your project, you can clone it and host it on your cPanel account.

To clone an existing repository, perform the following steps:

1) SSH to log in to your cPanel account on the command line.

2) To store your repository, it needs a new directory. To create a new directory run the following command:

mkdir -p ~/Project

3) Then you need to navigate to the newly created directory. To navigate to the newly-created directory, run the following command:

cd ~/Project

4) To clone the repository, run the following command, where url represents the full Git URL of the existing repository to clone:

git clone url example.git

Note: Many developers host their code repositories on GitHub. GitHub repository URLs generally be like, Where Account represents the GitHub account name and example represents the repository name.

5) Push local changes to the hosted repository.

After you complete all the steps mentioned above, you can make changes to the repository’s files on your local computer. You must run the following command in order to make the changes that you make on your local computer to the hosted repository:

git push origin master -u –exec=/usr/local/cpanel/3rdparty/bin/git-receive-pack

This command pushes your revisions to the copy of the repository that exists on your cPanel account.


If you need any further assistance please contact our support department.


Leave a Reply