Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Well, this is an idea that came to my mind a couple days ago and I could figured out how to do it (and even if it would be possible).

My idea would displaying a different branch when you access the website with a different address. For example :

  • mywebsite.com would use the master branch

  • dev.mywebsite.com would use another one

So, here it is. Don't know if it would be possible, but, who knows :)

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Yes, this can be done.

You'll need to configure Apache to point each domain to the appropriate subdirectories within the repository. You can use the --shared option of git-clone to keep from duplicating the backing files. Make sure you configure Apache to exclude access to any paths starting with .git.

You can use scripted git up commands to pull from your repository. You could also make use of atomic directory moves and a scripted git-archive for more overhead, but "clean" directories that keep the backing files off your server.

share|improve this answer
    
I'll dig into this, thanks :) –  Axiol Sep 13 '12 at 20:59

Git repository as itself cannot be used as a source for website files. You need to checkout the files from a branch to your working tree. These working tree files can then act as a web content.

The main problem here is that you can't practically checkout files from one git repository to two different working trees (that you'll then bind to your apache subdomains).

But what you can do is to have two more repositories for both of your subdomains. You can then use git hooks in your main repository to post commits to both of the "deployment repos" and then checkout the files in them from different branches.

You can find examples and a nice graph visualizing a similar setup at http://www.dejaaugustine.com/2011/05/leveraging-git-as-a-full-fledged-web-development-tool/.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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