+254725682556 +254725052660 info@ziprof.co.ke
Client Area

Hosting

How to Deploy Your Website Using Git Version Control on Your Hosting Account

Git lets you deploy your website's code straight from a repository instead of uploading files one by one with an FTP client. If you already keep your website's code in a Git repository, you can connect your hosting account to it and pull in updates with a few clicks in cPanel, or a couple of commands if you're on DirectAdmin.

Before You Start

You'll need the following before setting up Git deployment:

  • SSH access enabled on your hosting account. Both panels rely on it to reach a remote repository.
  • The clone URL of your Git repository, either an HTTPS URL or an SSH URL.
  • If the repository is private, a way to authorize your hosting account to access it, usually by adding a deploy key or using a personal access token from wherever the repository is hosted.
If SSH access isn't enabled on your account yet, turn it on first. See our guide on enabling SSH access.

Deploying With Git

In cPanel

  1. Log in to cPanel and, under Files, click Git™ Version Control.
  2. Click Create.
  3. Switch on Clone a Repository and paste the repository's address into the Clone URL field.
  4. Set the Repository Path to where you want the files to live on your account. This can be your public_html folder, or a separate folder you deploy from, depending on how your project is built.
  5. Click Create to clone the repository.
  6. To bring in future changes, return to Git™ Version Control, click Manage next to the repository, open the Pull or Deploy tab, click Update from Remote, then click Deploy HEAD Commit to copy the latest files into your deployment path.

If the repository is private, open SSH Access in cPanel to generate or view your account's SSH key, then add the public key as a deploy key on the repository host before cloning.

In DirectAdmin

Most DirectAdmin installations don't include a built-in Git tool, so you'll deploy over SSH instead.

  1. Connect to your hosting account using an SSH client, such as PuTTY on Windows or Terminal on Mac and Linux, with your hosting username and password or SSH key.
  2. Move into the folder you want to deploy to, for example: cd domains/yourdomain.com/public_html.
  3. Run git clone {repository-url} . to clone the repository into that folder. The folder needs to be empty for this to work, or you can clone into a new folder and move the files afterward.
  4. For future updates, reconnect over SSH, move into the cloned folder, and run git pull to fetch and apply the latest changes.

Keep Your Repository Out of Public View

A cloned repository includes a hidden .git folder containing your project's full history. If this folder sits inside a publicly accessible web folder like public_html and isn't blocked, visitors could potentially browse or download it.

If you deploy directly into public_html, password-protect or block public access to the .git folder. Better yet, clone the repository into a private folder outside your web root and deploy only the finished files into public_html.