This guide describes how to create a git server on your account. This is an advanced guide that requires some familiarity with SSH and the Linux shell. Be sure you know what you’re doing before proceeding!
Note that this is not the same as cloning a git repo that’s hosted elsewhere (such as on bitbucket or Github). The objective of this guide is to host your own repository rather than make use of code hosted in some other hosted repository. This guide is not connected to Plesk Onyx’s built in Git functionality, which allows you to clone a repository hosted elsewhere.
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:
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 email@example.com
b. Commit the project to the repo:
git clone --bare project repo.git
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:
Allow from all
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!