CloudLinux.ro
Dev environments

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 pricing

Related tutorials