Web Hosting Blog by Nest Nepal | Domain & Hosting Tips

Using Git with cPanel: How to Version Control Your Website (2025 Pro Guide)

Gone are the days of dragging and dropping files over FTP and manually updating production websites. Today, smart developers and digital businesses rely on control systems like Git Version to manage their codebases, collaborate effectively, and streamline deployments.

git-version

And here’s the good news: cPanel comes with built-in Git support! That means you can bring the power of Git workflows into your shared or VPS hosting environment.

This guide will walk you through everything, from setting up a repository to deploying updates from Git to your live website, all securely and professionally.

Why Use Git with cPanel?

Before jumping into the steps, let’s understand why Git and cPanel together make so much sense:

  • Safe deployments: Rollback anytime.
  • Team collaboration: Work with others using pull/push workflows.
  • Production-ready code: No more accidental overwrites.
  • Secure codebase: SSH-authenticated pushes.
  • Cleaner workflow: You work locally, push remotely, done.

Prerequisites

To follow this guide, you’ll need:

cPanel
  • A hosting account with cPanel (v90 or above)
  • Git is installed on your local machine (Windows/macOS/Linux)
  • SSH access is enabled on your hosting account (we’ll show you how)
  • Optional: A basic Laravel/PHP project (or any web project you want to deploy)

Step 1: Create a Git Repository in cPanel

  1. Log in to your cPanel dashboard.
  2. Search for “Git Version Control” in the search bar.
  3. Click on “Create Repository.”
  4. Choose a clone repository if your code is on GitHub or GitLab. Or create a new empty one if you’re initializing it later.
    • Repository path: /home/youruser/repositories/my-website
    • Repository name: my-website
  5. Hit Create.

✅ Your Git repo is now live inside your hosting account.

Step 2: Set Up SSH Access (For Secure Pushes)

Using Git securely requires SSH authentication.

On Your Local Computer:

ssh-keygen -t rsa -b 4096 -C “your@email.com”

  • Save the file (press Enter to use the default path ~/.ssh/id_rsa)
  • Then copy your public key:

cat ~/.ssh/id_rsa.pub

On cPanel:

  1. Open SSH Access > Manage SSH Keys
  2. Click Import Key
  3. Paste your id_rsa.pub contents into the public key box
  4. Authorize the key

Done! You can now push to your repo securely.

Step 3: Add Remote & Push Code from Local Git

From your terminal:

cd your-local-project-folder

git init

git remote add live ssh://youruser@yourdomain.com/home/youruser/repositories/my-website

git add.

git commit -m “Initial commit”

git push live master

Now your code lives on your server.

If you’re using GitHub or GitLab, you can instead have cPanel pull directly from those remotes. More on that later.

Step 4: Deploy the Code to Public_HTML (Live Website)

Just because the repo lives on your server doesn’t mean it’s live yet.

Let’s deploy it:

  1. Go back to Git Version Control in cPanel
  2. Click Manage on your repository
  3. Under Deployment, choose:
    • Deployment directory: /public_html or any subfolder.
    • Deployment branch: usually master or main
  4. Click Deploy HEAD Commit

Boom! Git now powers your website.

Optional: Auto-Deploy on Push (Post-Receive Hook)

Want changes to go live automatically every time you push? Set up auto-deploy:

  1. In cPanel’s File Manager, go to your .git/hooks folder inside your repo path.
  2. Edit or create a post-receive file:

#!/bin/bash

GIT_WORK_TREE=/home/youruser/public_html git checkout -f

  1. Make it executable:

chmod +x post-receive

Now every push = auto update.

Git Workflow Example: Laravel App Deployment

Let’s say you’re deploying a Laravel app:

  • Your repo has the entire Laravel structure
  • Public files are inside public/
  • You want public/ to be your public_html

Solution:

  1. Set repo in /home/user/laravel-app
  2. Deploy only public/ to /home/user/public_html
  3. Point index.php and bootstrap to correct paths (adjust if needed)

Bonus: You can use .env.production and symlink it as .env for live config.

git-support
Revision control system. Word Git of the yellow square pixels on a black matrix background. 3D illustration image

Best Practices for Git + cPanel Deployments

  • Use separate branches for staging and production
  • Don’t commit sensitive .env or config files; use server-only copies
  • Set proper file permissions after deploy (especially for storage/ and bootstrap/cache/)
  • Enable 2FA on GitHub and use deploy keys
  • Keep a backup before you deploy (always!)

Recap: Git-Powered Hosting = Smarter Web Development

With Git and cPanel working together, your workflow becomes:

  • Develop locally
  • Push securely
  • Deploy instantly
  • It’s faster, safer, and way more professional than manual uploads.

Whether you’re a solo developer, an agency, or a startup, mastering Git-based deployment on shared hosting gives you an edge.

So go ahead and set up that repo, push your code, and take control of your website’s future! Need a Git-friendly hosting provider in Nepal? Most modern cPanel hosts support Git (like Nest Nepal), so choose one that gives you SSH and Git Version Control in your panel.

Share this article
Shareable URL
Prev Post

Boost WordPress Speed Without Plugins: Advanced Manual Optimization Techniques (2025)

Next Post

The Ultimate Guide to Email Deliverability: Ensuring Your Business Emails Land in the Inbox

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next