1

I hope I have managed to explain this problem well:

I have project files at (paths simplified):

/local/projects/example/client
/local/projects/example/server

To keep client and server code in sync, I simply keep a git repository at /projects/example. I don't want to be bothered with Git submodules for this purpose.

However, in order to 1) test the server code locally, and 2) sync the server code with the live server (using rsync), I also need to keep the server code at my local /domains folder, which holds all my domains:

/local/domains/example.com/
/local/domains/example2.com/
/local/domains/example3.com/

I tried symlinking from example/server to domains/example.com but Git does not follow symlinks. I tried hardlinks, but they seemed to get broken off suddenly for unknown reasons, possibly caused by Git checking out old versions. And manual copy scripts would be really cumbersome.

I could point my local Apache to example/server rather than domains/example.com when testing locally, but then I have to do chmod and chgrp for the entire path three up to this server which does not seem right.

Can anyone come up with a good setup that will

  • keep client and server code in sync in Git
  • keep example/server and domains/example in sync automatically

1 Answer 1

0

You should be able to checkout your local git repo (/local/projects/example/server) directly at your local live Apache root directory (/local/domains/example.com/), as in "Maintain multiple simultaneously-accessible versions of website remotely using Git", using a post-receive hook.

GIT_DIR=/local/projects/example/server/.git GIT_WORK_TREE=/local/domains/example.com git checkout master -f

You just need to make sure adjust your umask in order for Apache to work with said checked out files. (for instance umask 002 will set all the files to 775)

2
  • Interesting! How does it work? Every time I commit or pull something in projects, it is automatically checked out in domains? How about uncommited changes that I want to upload to the live server for testing (I do this a lot), are they mirrored to domains for every file I save in projects, or do I have to commit for the changes to propagate from domains to projects?
    – forthrin
    Oct 5, 2012 at 12:54
  • @forthrin I prefer committing changes in a feature branch, and push it to a bare repo (on which that pre-receive hook is set): instant deployment.
    – VonC
    Oct 5, 2012 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.