+91 88 00 563434 [email protected] Blog open-book Knowledge Base

Find Solutions in Our Knowledge Base

How to Host Git Repositories on a cPanel Account

You are here:
Sharing is Caring

Hosting Git Repositories on a cPanel Account

If you have the right permissions, cPanel accounts can host Git repositories. Git is an environmentally friendly open-source Version Control System (VCS). It tracks content such as files and directories and manages changes to a project without overwriting any part of it.

 

Features of a VCS:

Enables developers to work simultaneously.

Prevents overwriting each other’s modifications.

Maintains a history of every version.

 

There are two types of VCS: 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 and manages changes to a project without overwriting any part of it. Thus, multiple users can handle files concurrently.

 

The advantages of Git are listed below:

Free and open source.

Fast and small.

Implicit backup.

Security.

No need for powerful hardware.

Easier branching.

 

Steps to host a Git repository on your cPanel Account:

Create a repository.

Follow the steps below to create a new repository:

1) Access your cPanel account through the command line using SSH.

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

mkdir -p ~/Project/example

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

cd ~/Project/example

4) Initialize the directory as a Git repository by running the following command:

git init

 

Update the repository’s Git configuration.

This step is optional and configures the Git repository to stay updated 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 through 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 in your project, you can clone it and host it on your cPanel account.

To clone an existing repository, follow the steps below:

1) SSH into your cPanel account using the command line.

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

mkdir -p ~/Project

3) Then 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 typically look like this: https://github.com/Account/example.git. Where Account represents the GitHub account name and example represents the repository name.

5) Push local changes to the hosted repository.

After completing all the mentioned steps, you can make changes to the repository’s files on your local computer. To transfer the changes you made on your local computer to the hosted repository, run the following command:

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.

 


Sharing is Caring

Leave a Comment

Table of Contents