Child pages
  • How to Host Git Repositories on a cPanel Account
Skip to end of metadata
Go to start of metadata

Overview

With the appropriate permissions, cPanel accounts can host Git™ repositories. Git's version control software tracks changes in a system of files that multiple users can manage simultaneously. 

This tutorial creates or clones a new Git repository, updates the repository's configuration, and clones the repository locally for updates.

Important:

To perform the steps in this tutorial, you must ensure that the following statements are true:

  • You must possess an active cPanel account with available disk space.
  • Your system administrator must enable the Shell Access setting for your cPanel account.
  • You must register your public key in cPanel's SSH Access interface (cPanel >> Home >> Security >> SSH Access) and authorize it for SSH access.

Notes:

  • Throughout this tutorial, example represents the repository name and Project represents the directory that contains the repository.
  • For more information about Git, read Git's documentation.

Host a Git repository on your cPanel account


Create a repository.

Note:

If a Git repository already exists for your project, you can clone it to your cPanel account instead. To do this, perform the steps in the Clone an existing repository to your cPanel account section below, and then proceed to Step 2.

To create a new repository, perform the following steps:

  1. Use SSH to log in to your cPanel account on the command line.
  2. To create a new directory to store your repository, run the following command:

    mkdir -p ~/Project/example
  3. To navigate to the newly-created directory, run the following command:

    cd ~/Project/example
  4. To initialize the directory as a Git repository, run the following command:

    git init

 


 

Update the repository's Git configuration.

This optional step configures the Git repository to remain up to date as you push changes from the local branch. For more information about Git's configuration file and its options, read Git's git-config documentation.

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, access your local computer via the command line and run the following command:

git clone ssh://username@hostname:/home/username/Project/example.git
  • username represents the cPanel account username.
  • hostname represents the hostname for the server that hosts your cPanel account.

 


 

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. Use SSH to log in to your cPanel account on the command line.
  2. To create a new directory to store your repository, run the following command:

    mkdir -p ~/Project
  3. 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 resemble the following example, where Account represents the GitHub account name and example represents the repository name:

    https://github.com/Account/example.git

 


Push local changes to the hosted repository.

After you finish this tutorial, you can make changes to the repository's files on your local computer. You must run the following command in order to push 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.

 

 

Additional documentation

There is no content with the specified labels

There is no content with the specified labels