Version Control with Git
Git is a powerful version control system that lets you track changes to your code, collaborate with others, and deploy updates to your hosting account. SillyHost supports Git on all hosting plans with SSH access enabled.
Prerequisites
- SSH access must be enabled on your hosting account
- Git must be installed on your local development machine
- A remote repository on GitHub, GitLab, Bitbucket, or similar service (optional but recommended)
Setting Up a Git Repository on Your Server
- Connect via SSH – Open your terminal and connect:
ssh username@yourdomain.com - Navigate to your web root –
cd ~/public_html - Initialise a repository –
git init - Add your files –
git add .followed bygit commit -m "Initial commit"
Deploying from a Remote Repository
A more common approach is to push code from your local machine to a remote repository, then pull it onto the server:
- SSH into your server and navigate to your web root
- Clone your repository:
git clone https://github.com/yourusername/yourrepo.git . - To update the site with the latest changes:
git pull origin main
Using cPanel Git Version Control
SillyHost also supports cPanel's built-in Git deployment tool:
- In cPanel, go to Files > Git Version Control
- Click Create and enter your remote repository URL
- Set the repository path (e.g.,
/home/username/repositories/mysite) - Configure a
.cpanel.ymldeployment file in your repository root to define deployment tasks
Example .cpanel.yml
This file tells cPanel what to do when you push code:
---
deployment:
tasks:
- export DEPLOYPATH=/home/username/public_html/
- /bin/cp -R * $DEPLOYPATH
Best Practices
- Never commit sensitive files like
wp-config.phpor.env— use a.gitignorefile - Use branches for development and only deploy from your main branch
- Test locally before pushing to production