UnderHost
Knowledgebase Docs

Git integration in CloudPanel: deploy from GitHub

Setup Git in CloudPanel. Deploy from GitHub, GitLab, Bitbucket. Auto-pull on push, SSH keys, continuous deployment, webhook configuration.

On this page

Git enables version control and collaborative development. CloudPanel integrates Git to pull code directly from GitHub, GitLab, or Bitbucket. Deploy latest code with a single command or automatically when you push. Perfect for development workflows, team projects, and continuous deployment pipelines.

Git Overview

Why Git integration matters:

  • Version control: Track every code change, revert if needed
  • Collaboration: Multiple developers work simultaneously
  • Deployment: Deploy code directly from repository
  • Automation: Webhooks trigger deploys on push (no manual FTP)
  • CI/CD: Integrate with automated testing and deployment

Git in CloudPanel

CloudPanel Git features:**

  • Clone repository to website directory
  • Pull latest code with one command
  • Webhook support for automatic deploys
  • SSH key management
  • Multi-branch support
  • Deploy history and logs

Setup SSH Keys

SSH keys authenticate with GitHub/GitLab without passwords:**

Step 1: Generate SSH key pair on your server**

ssh-keygen -t ed25519 -C "deployment@yourdomain.com" -f /root/.ssh/id_deploy
# Leave passphrase empty for automated deploys

Step 2: Copy public key to GitHub**

# Display public key
cat /root/.ssh/id_deploy.pub

# Copy entire output

GitHub settings:**

  1. Repository → Settings → Deploy Keys
  2. Click "Add deploy key"
  3. Paste public key from above
  4. Check "Allow write access" if deployments need to push back
  5. Save

Alternative: Add to GitHub account keys (accessible to all repos):**

  1. GitHub profile → Settings → SSH and GPG keys
  2. Click "New SSH key"
  3. Paste public key
  4. Save

Clone Repository

Method 1: Via CloudPanel Web Interface**

  1. CloudPanel → Websites → [Your Domain]
  2. Click "Git"
  3. Click "Clone Repository"
  4. Enter repository URL:
    • SSH format (recommended): git@github.com:youruser/yourrepo.git
    • HTTPS format: https://github.com/youruser/yourrepo.git
  5. Enter branch: main (or master, develop)
  6. Click "Clone"

Method 2: Via SSH command**

cd /home/cloudpanel/www/yourdomain.com
git clone git@github.com:youruser/yourrepo.git .
git checkout main

Webhook Configuration

Webhooks automatically pull code when you push to GitHub:**

Step 1: Generate webhook URL in CloudPanel**

  1. CloudPanel → Websites → [Your Domain] → Git
  2. Copy "Webhook URL" (looks like: https://yourdomain.com/webhook/secret-token)

Step 2: Add webhook to GitHub**

  1. Repository → Settings → Webhooks
  2. Click "Add webhook"
  3. Paste CloudPanel webhook URL
  4. Event type: "Push events"
  5. Click "Add webhook"

Step 3: Test webhook**

  1. Make a commit and push to GitHub
  2. CloudPanel automatically pulls latest code
  3. View deployment log: CloudPanel → Websites → [Domain] → Git → Logs

Auto-Deploy on Push

Automated deployment workflow:**

1. Developer commits and pushes code to GitHub
   git commit -am "Update homepage"
   git push origin main

2. GitHub sends webhook to CloudPanel
   POST https://yourdomain.com/webhook/...

3. CloudPanel receives webhook
   Extracts repository and branch info
   Executes: git pull origin main

4. New code deployed
   Live immediately on yourdomain.com

Optional: Run deployment scripts**

After pulling code, CloudPanel can execute post-deploy scripts:

#!/bin/bash
# Post-deploy script (.cloudpanel-deploy.sh)

# Install dependencies
npm install
npm run build

# Or Python
pip install -r requirements.txt

# Or PHP/Laravel
composer install
php artisan migrate --force

Recommended Workflow

Development → Staging → Production**

  1. Development: Local git repo, push to GitHub develop branch
  2. Staging: Separate domain/VPS pulls from GitHub develop branch via webhook
  3. Production: Main domain pulls from GitHub main branch via webhook after testing

Branch strategy:**

main → Stable, production code
↑
develop → Testing, next release
↑
feature/login → Individual features

Workflow:
1. Create feature branch: git checkout -b feature/login
2. Make changes, commit
3. Push to GitHub: git push origin feature/login
4. Create pull request
5. Code review, approve
6. Merge to develop
7. Test on staging (pulls develop branch)
8. Merge develop → main
9. Production updates automatically

Troubleshooting

Git clone fails with "Permission denied":**

  • Check SSH key is added to GitHub/GitLab
  • Verify key permissions: chmod 600 /root/.ssh/id_deploy
  • Test connection: ssh -i /root/.ssh/id_deploy git@github.com

Webhook not triggering auto-deploy:**

  • Verify webhook URL is correct in GitHub settings
  • Check GitHub webhook delivery logs (Settings → Webhooks → Recent Deliveries)
  • Verify CloudPanel firewall allows webhook requests
  • Check CloudPanel logs: journalctl -u cloudpanel -f

Files not updating after push:**

  • Verify webhook is configured correctly
  • Check file permissions (CloudPanel user must have write access)
  • Manually pull: cd /path/to/site && git pull origin main
  • Review deployment logs in CloudPanel

Merge conflicts from server-side changes:**

  • Avoid editing files directly on server
  • Always edit locally, commit, push to GitHub
  • If conflicts occur: git reset --hard origin/main (dangerous, data loss possible)
Git simplifies deployment and team collaboration

Webhooks eliminate manual FTP uploads. Developers focus on code; deployment is automatic. Perfect for modern development workflows and continuous deployment.

Related: CloudPanel setup | GitHub deployment | GitLab integration | Continuous deployment

Was this article helpful?

Need CloudPanel on a server?

Use CloudPanel on an UnderHost VPS or dedicated server for fast PHP app and WordPress hosting without a heavy panel stack.

Related articles

Back to CloudPanel