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:**
- Repository → Settings → Deploy Keys
- Click "Add deploy key"
- Paste public key from above
- Check "Allow write access" if deployments need to push back
- Save
Alternative: Add to GitHub account keys (accessible to all repos):**
- GitHub profile → Settings → SSH and GPG keys
- Click "New SSH key"
- Paste public key
- Save
Clone Repository
Method 1: Via CloudPanel Web Interface**
- CloudPanel → Websites → [Your Domain]
- Click "Git"
- Click "Clone Repository"
- Enter repository URL:
- SSH format (recommended):
git@github.com:youruser/yourrepo.git - HTTPS format:
https://github.com/youruser/yourrepo.git
- SSH format (recommended):
- Enter branch:
main(ormaster,develop) - 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**
- CloudPanel → Websites → [Your Domain] → Git
- Copy "Webhook URL" (looks like:
https://yourdomain.com/webhook/secret-token)
Step 2: Add webhook to GitHub**
- Repository → Settings → Webhooks
- Click "Add webhook"
- Paste CloudPanel webhook URL
- Event type: "Push events"
- Click "Add webhook"
Step 3: Test webhook**
- Make a commit and push to GitHub
- CloudPanel automatically pulls latest code
- 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**
- Development: Local git repo, push to GitHub
developbranch - Staging: Separate domain/VPS pulls from GitHub
developbranch via webhook - Production: Main domain pulls from GitHub
mainbranch 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)
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
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.





















