Home > Help Center > Shared Hosting > Control Panel > Git Version Control in cPanel

Git Version Control in cPanel

high performance managed hosting

We'll show you how to use the updated Git interface for version control in cPanel and WHM Version 74. This feature allows you to easily host Git repositories in your cPanel account.

Not sure what Git is or why do you want to host repositories in your cPanel account?

Git version control software tracks changes to a file system that can be managed by multiple users simultaneously. While the main use of Git is software development, you can use it to track the changes upon any set of files, even plain text files.

Git does all this by using repositories.

Each Git repository stores the project files and information about the revisions (versions) of these files over time.

In addition to these basics, Git offers many features that allow you to view information about your revisions and files, find the user or change, that has caused a problem, make edits, or make ongoing changes.

If your cPanel hosting account includes SSH access, you can also use Git from a command line.

  • Without shell access, you can only create, clone, delete, and view repositories.
  • You can use the cPanel Terminal interface (cPanel > Home > Advanced > Terminal) to access Git from a command line directly in your cPanel.

The following tasks require the use of a command line:

  • SSH for cloning private repositories.
  • Using multiple remote repositories - this method is only recommended for advanced Git users.

If you add or remove Git repositories through the command line, you may see an incorrect list of repositories in this interface.

After this very basic information, log into your cPanel account. In the cPanel main screen, find the Files tab and then click on the Git™ Version Control link or type git in the search box:

Git version control overview

The Git version management interface will appear on the screen:

Create new repository in Git version control

The main interface shows a list of cPanel accounts, without any repositories, so you should click on the Create button to create one.

A new interface will appear:

Options during the creation of new repository

Clone a Repository serves as a switch and determines whether we want to clone a repository from somewhere else, perhaps a repository from Github. Cloning means we make a copy of the repository that we clone, and then we can use Git to send our changes to this repository.

The interface allows cloning by default.

If you clone a repository, you also need to enter the clone URL into the Clone URL text box. The clone URLs start with HTTP, SSH or Git protocol. You get this URL from where the repository, you are going to clone, is stored. For most repositories, finding the URL is extremely easy. For example, we will clone WP-underscores-e-Bootstrap-4.1 from Github:

Bootstrap GitHub repository

If we open the File Manager and navigate to the specified directory, we will see a full copy of the WP-underscores-e-Bootstrap-4.1 directories and files in Github:

cpanel git

The cloned repository is saved in a table in the Git™ Version Control main interface:

FileManager Git example

If you want to create a completely new repository so you can start a new project from scratch, simply click on the switch to disable cloning.

Then, in the storage text box, enter the path to the directory where you want to store the repository. The system automatically fills this value, but you can change it if you do not want to use this auto-generated path.

The path should point to a directory in the start directory of your cPanel account, and you can only save one repository per directory, so you need to enter a directory that does not have a repository yet. If the directory does not exist, the system will create it with the repository.

In the repository name box, type the name you want the cPanel interface to display for the new repository. This name simply makes it easier to identify your repositories so you can enter the name you want. The system automatically fills this value, but you can change it if you do not want an automatically generated name.

If you want the system to return you to the creation form after creating this repository, mark the box next to the Create Another link, then click the Create button to create the new repository:

View existing repositories in Git version control

Now the directory contains the repository we just created. If you clone a very large repository, it may take some time for the system to complete the process. Until the cloning of the repository completes, you can do nothing but look at the name and path of the repository.

After creating the repository for the new project, the following helpful instructions for managing cPanel repository over SSH are loaded on a new screen.

Run these commands on your local computer.

For an existing project:

Step 1: Navigate to the repository directory:

cd /path/to/your/repo

Step 2: Configure your local repository to be able to import (push) the cPanel-hosted repository:

git remote add origin ssh://hostpulsedemo@hostpulse-demo.com:22022/home/hostpulsedemo/git/newgit

git push -u origin master

To start a new project:

Step 1: Clone the cPanel hosted repository on your local computer and go to its directory:

git clone ssh://hostpulsedemo@hostpulse-demo.com:22022/home/hostpulsedemo/git/newgit

cd newgit

Step 2: Create a README file:

echo "# README" >> README.md

Step 3: Include the README file in the project:

git add README.md git commit -m "Initial Commit" git push -u origin master

  • In a separate article, we'll show you how to use the SSH Access option in cPanel and generate SSH Keys directly from your cPanel to access the server from your computer.

  • We will also show you how to use the Terminal option in cPanel to directly access the server via the command line.

The new repository is also saved in the main interface table and shows the name and path of the repository. You can click the Manage button to update your storage settings:

View existing repositories in your cPanel

You can click the History button to go to the Gitweb web interface that lets you view your store history and files, or you can click the Delete button to permanently delete the repository. Be careful, because when you delete a repository all data and files will be permanently deleted.

If you want to see more information for a repository, click on the arrow to the left of the repository name - it will show you active repository information and branch URL if you want to clone this repository elsewhere:

Repository options

Click the Copy button to copy this URL to your clipboard. To open the repositories directory (in the example - /home/hostpulsedemo/git/understrap) in the file manager, click the File Manager button. A new browser tab will open. Be careful what you are doing here - if you make changes or delete the .git directory, it can 'break' your repository.

Click the Manage button to load a new interface. Below basic information, you can change the name of the repository or check another branch. If you make any changes, then click the Update button.

Here you can view the repository branch information, you can also click the History button to go to Gitweb and the URL of the branch here is the same as the one in the repository. Gitweb allows you to surf the repository and see its history and content.

Under the arrow icon, you can see the path of the repository and the remote URL. You can see the currently ticked information about the branch and HEAD. On the right side, if you've ever deployed the repository via the commit command, you'll see information about the latest deployment. You can click on the update from a remote device to download new changes from the remote repository.

Click on deploy head commit to make new changes from the cPanel hosted repository.

Edit repository

Important: You can not change the path of the repository for existing repositories. Whenever you change the repository settings, the system also pulls the changes from the remote repository.

To change an existing repository, follow these steps:

Click the Manage button on the desired repository. A new interface will appear. To update the branch you have registered at this time, select the branch you want from the Active Branch menu.

Note: This menu only displays remote branches. This menu will not show any clones that only exist locally in your cPanel account.

To update the repository name, enter the new name in the repository name field. Click the Update button or Return to Repository List to return to the repositories list.

Restrictions on the repository path

This feature requires several restrictions on the paths of the repository.

The .git directory

Attention: Do not modify or delete the .git directory of the repository or its contents. Changes in this data may cause irreparable fracture of the repository.

The system worldwide does not allow public access to .git directories of repositories.

Character Restrictions

You can not create, delete, or view repositories, which path include a blank space or any of the following characters:

\ * | "" <> & @ $ {};?: =% # `

cPanel-controlled directories

You can not create, delete, or view repositories in the following directories:

  • .panel
  • .trash
  • etc
  • mail
  • ssl
  • tmp
  • logs
  • .cphorde
  • spamassassin
  • .htpasswds
  • var
  • cgi-bin
  • .ssh
  • perl5
  • access-logs

Still not finding what you're looking for?

Contact our support team with any additional questions or concerns.

Contact support