How to deploy with a simple git push
Updated 7/20/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
How to create a systemd service for your app
Make your app start automatically and restart itself if it stops, with a systemd service.
Updated 7/20/2026Dev environmentsHow to keep sessions running after disconnect with tmux
tmux keeps your terminal sessions alive even after you close SSH, ideal for long-running tasks.
Updated 7/20/2026Dev environmentsHow to manage environment variables and secrets
Keep passwords and keys out of your code, in environment variables, safely and correctly.
Updated 7/20/2026