For the main nowacki.org site I have a bare git repository set up on the VPS. I push to this repo when I make a change to the site, which automatically updates the directory containing the site that is served by nginx. I set this up many years ago, but it went something like this DO tutorial.
In short, create a bare repo somewhere on your server (via git init --bare
). Then inside the hooks/
directory, create a post-receive
file with the following contents:
#!/bin/sh
git --work-tree=/var/www/nowacki.org --git-dir=/var/repo/www.nowacki.org.git checkout -f
Here work-tree
is the directory contianing the site, and git-dir
is the location of the bare repo you created. Make this file executable.
On your local machine, create a new repo (with git init
) and add the bare repository you just created as a remote: git remote add origin ssh://user@example.org/var/repo/www.nowacki.org.git
, substituting your user and server address. Now you should be able to commit locally and push those changes to the remote server. These will then be updated in the work-tree
directory, which you point to in your nginx (or other web server) configuration file.