If you add the following script as a hooks/post-receive
hook to a bare git repository foo.git
:
#!/bin/sh
GIT_WORK_TREE=/bar git checkout -f
then whenever someone pushes to the repository the current state will be updated in directory bar
.
This requires bar
and foo.git
to be on the same machine.
What's the easiest way to modify it so that the checkout is made on a remote machine (say baz:/bar
) ?
One way would be to:
#!/bin/sh
GIT_WORK_TREE=/tmp/bar git checkout -f
rsync ... /tmp/bar baz:/bar
Is there a better way? Perhaps not requiring an intermediate temp directory? (If not what are the correct options to pass to rsync such that the resulting directory is indentical to being checked out directly?)