GIT push-to-sync

This method can be usefull if you are using git as revision control system e.g. for a website and want an easy way to publish changes when they are tested and found to be ok.

Create read-only copy of git repo for HTTP access

In your GIT repo, you just need to create a script that is triggerd after every push to that repo. In git, such thing is called "hooks".

#!/bin/sh export http_dir="/srv/http/var/htdoc/git" read oldrev newrev refname branch=${refname#refs/heads/} repo=${PWD##*/} if [ "${branch}" = "master" ]; then umask 0022 rm -rf ${http_dir}/${repo} git clone --bare --local /srv/git/${repo} ${http_dir}/${repo} cd ${http_dir}/${repo} && git update-server-info else echo "Ignoring update for branch ${branch}" fi
chmod a+x hooks/post-receive