Git Deployment to Hosting and VPS: Automate with Hooks

Hosting & cPanel · 15.03.2026
Git Deployment to Hosting and VPS: Automate with Hooks

Git Bare Repo on VPS

git init --bare /var/repo/mysite.git
# post-receive hook:
GIT_WORK_TREE=/var/www/mysite git checkout -f main
# Locally:
git remote add production user@server:/var/repo/mysite.git
git push production main
← Back to Knowledge Base Ask Support