2

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 :)

2 Answers 2

2

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.

0
0

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/.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .