How to set up a git repository with Plesk

git-repo-create-with-plesk

This guide describes how to create a git repository server on your Websavers hosting account. This is an advanced guide that requires some familiarity with SSH and the Linux shell.

Tip: If you wish to clone/deploy a repository hosted on GitHub, BitBucket, or any other git server, see the Plesk guide to deploying with git found here.

 1. Create domain like git.yourdomain.com (do not enable www prefix)

 2. Create password protected directory and accounts

a. In Plesk go to Password Protected Directories
b. Choose Add Protected Directory
c. Provide directory name like /repo.git
d. Check Non-SSL (your domain should by default be configured to use SSL on the non-SSL directory anyway).
e. Make the Header Text the name of the repository and choose OK
f. Click Add New User and add whatever users you’d like to have access to the repo. You can come back and easily manage users from within Plesk rather than manually via .htaccess file edits.

 3. Login via SSH and proceed as follows

a. Create your project and file:
cd httpdocs
mkdir project
cd project
git init*
touch README
git add .
git commit -m"first checkin"

* as warned you should set your username and email address accordingly *

git config –global user.name “Your Name”
git config –global user.email you@example.com

b. Commit the project to the repo:
cd ..
git clone --bare project repo.git
cd repo.git
touch git-daemon-export-ok
git --bare update-server-info

At this point you don’t need the project folder anymore, since you have cloned it to the repo
rm -rf ../project

 4. Have us allows Dav access to your repo

Create a support ticket requesting that we add the following to your subdomain’s vhost.conf:

<Directory /var/www/vhosts/git.yourdomain.com/httpdocs/repo.git>
Dav On
Allow from all
</Directory>

Once we have completed this last step for you, you will be able to access your repo using:

git clone http://git.yourdomain.com/repo.git

If you will be accessing the repo from a non-secure connection and wish to protect both access to your repository as well as your usernames and passwords, you will want to ensure SSL is enabled by always using https in your connection details.

You will need to obtain a valid SSL certificate for the exact domain name under which you set up your git repository (such as git.yourdomain.com as in the example above). You can do this by purchasing one from us (starting at $24.99) or get a free Let’s Encrypt certificate.

*If none of the git commands work on your server, we’ll need to install git. Simply open a support ticket asking that we run the following command on the server on which your account is hosted:

yum install git-all --enablerepo=rpmforge

Did you find this guide to setting up a Git repo helpful? Host your project with Websavers and get access to our experts via support tickets!

Jordan Schelew

Jordan has been working with computers, security, and network systems since the 90s and is a managing partner at Websavers Inc. As a founder of the company, he's been in the web tech space for over 15 years.
WS-Logo-only-image-large

About Websavers

Websavers provides web services like Canadian WordPress Hosting and VPS Hosting to customers all over the globe, from hometown Halifax, CA to Auckland, NZ.

If this article helped you, our web services surely will as well! We might just be the perfect fit for you.

Leave a Comment