How to deploy with a simple git push
Updated 11/29/2026
The most pleasant deploy flow: you write code, run git push, and the server updates itself. Here is how to build it with a Git hook.
1. Create a bare repo on the server
mkdir -p /var/repo/site.git
cd /var/repo/site.git
git init --bare
2. Add a post-receive hook
Create /var/repo/site.git/hooks/post-receive:
#!/bin/bash
git --work-tree=/var/www/site --git-dir=/var/repo/site.git checkout -f main
cd /var/www/site
# build commands, for example:
composer install --no-dev
php artisan migrate --force
chmod +x /var/repo/site.git/hooks/post-receive
3. Add the server as a local remote
git remote add production root@SERVER_IP:/var/repo/site.git
git push production main
On every push, the hook checks the code out into the web directory and runs the build commands.
For more complex flows
When you need tests and multiple steps, move to a CI/CD pipeline. For visual deploys, see the Coolify app.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Error tracking for your applications with GlitchTip
Catch production exceptions with the Sentry SDKs on a small server: the project, the DSN, alerts and uptime.
Updated 11/29/2026Dev environmentsTest your application's email with smtp4dev
Send the email from Laravel, WordPress, Node or Python to a test SMTP server and read it in a web inbox, without it ever reaching real customers.
Updated 11/29/2026Dev environmentsHow to build a CI/CD pipeline
Automate testing and deploying your code on every change, with a CI/CD pipeline on your server.
Updated 11/29/2026