In production, I maintain two sites - beta and release. Each points to a different directory via a soft link (e.g.)
beta_public_html -> /home/scott/myapp/
The article Git push is worse than worsless has an interesting discussion about a similar issue.
One of its solution and conclusion involves:
So in your case,
In short: one step: git push. No more link to manage (since the directory no longer represent a branch in Git, unlike SVN)
Regarding the hook part, a post-receive hook in the bare repo could be all what you need
See Git Tip: Auto update working tree via post-receive hook
$ cd bare
$ chmod +x .git/hooks/post-receive
with a post-receive hook like
#!/bin/sh
cd ../../beta
env -i git reset --hard
cd ../../release
env -i git reset --hard
Note:
the
post-receivehook starts out with theGIT_DIRenvironment variable set to therepo/.gitfolder, so no matter what path you 'cd' into it will always try to run any following git commands there.
Fixing this is simply a matter of unsetting theGIT_DIR.
'env -i' does just that: it ignores the inherited environment completely and uses only the supplied variables and values.