Setting up GIT on CPanel Server Tutorial

For this tutorial, we will use a Windows 8 64bit machine as our client computer, and a CentOS CPanel server computer.

You can get the Git client from

If you have already started the process of installing Git on the CPanel server, you might cause a problem with Perl as installing Git from the repos can cause conflicts with Perl. Git is already installed on CPanel servers, so no installation is necessary. But, configuration is necessary as it is not yet user friendly for setting up your own repositories.

1) setup GIT and git user on server

alias git="/usr/local/cpanel/3rdparty/bin/git"
sudo adduser git

(you can add your SSH certificate if you want)
cat /tmp/ >> ~/.ssh/authorized_keys

– OR –

(you can make a password for the git user)
passwd git

2) setup repository for project and grant git user ownership

cd /opt/git
mkdir EXAMPLE.git
chown -R git ./EXAMPLE.git
cd EXAMPLE.git
git --bare init

3) remove git .bashrc and modify root .bashrc files

cd /home/git
mv ./.bashrc ./.bashrc_old
vi ~/.bashrc

(add this line to the root .bashrc file)

(save and quit using :wq in VIM)

The git server and project are setup, you can now commit or pull your files!

[optional] initiate git repo on project folder and commit

git init
git commit -a -m "initial commit"
git remote add origin git@SERVERIP:/opt/git/EXAMPLE.git
git push origin master

– OR –

[optional] transfer project files from remote server computer to client computer

Create folder on your client PC, right click in folder and click “GIT Bash”.

git clone git@SERVERIP:/opt/git/EXAMPLE.git