1

So I have a git repository that hold three folders. This is fine for my local web server. However, up on the live server, two of these folders need to be behind the webroot and one of them needs be in the webroot. I'd like to use a git repo on the server for easy pushing/pulling, but the folders need to go in different places.

Does anyone have a solution for this?

Thanks!

Mr Mikkél
  • 2,577
  • 4
  • 34
  • 52
  • 1
    Why don't you mirror your live setup in your development environment? In my experience a different development and live setup is error-prone. – topek May 18 '12 at 21:42
  • Well, that's still problematic. I don't have control over the www/ directory on the live server, but I still want stuff below it AND above it. – Mr Mikkél May 21 '12 at 09:40

2 Answers2

1

You basically have two options. You can either set up the webserver so that the one directory you want is in the webroot (by symlinking and allowing to follow symlinks, or by setting the document root appropriately) or have some external process copy them.

For the latter, you could have a simple copy cron job, or a slightly more sophisticated git commit hook that does the copying. If you used something like rsync, you would only copy things that have actually changed as well. You could of course take this approach further and have a full blown continuous integration system which, after running tests, copies the files into the correct place.

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
0

Because each Git repo needs to be a full copy of the data, you'll need to structure the repo so that when it's cloned on disk, the folders sit in the correct place from the start.

If you want more flexibility (e.g. partial/deep-level check-outs) then Subversion is actually a better fit.

I also second topek's recommendation to make sure that your dev/test setup matches production.

Matthew Skelton
  • 2,220
  • 21
  • 21