Using git to publish to a website

Citizen picture Citizen · Feb 8, 2011 · Viewed 10.3k times · Source

I used this guide to use git to autopublish my changes on my website when I push to my remote origin git repository:

http://www.lwp.ca/james/2010/03/using-git-to-manage-online-website-projects/

Here's my /hooks/post-update file:

cd ../../public_html/dir/wbg
env -i git pull

Here's my directory structure:

/home/git/wbg.git <-- my remote git repository

/home/public_html/dir/wbg <-- my web folder

When I run

git push origin master

The repository updates but my web folder is still empty. Any ideas?

Edit: if any future traffic sees this, my real problem was that BOTH your remote origin AND your destination website directory must be git repositories. You can't just set it up to copy your project to a new folder unless that folder is also a git repo.

Answer

Arrowmaster picture Arrowmaster · Feb 11, 2011

You can find a better alternative at http://toroid.org/ams/git-website-howto that only uses one git repository, and allows all metadata and previous history to remain outside of the DocumentRoot.

The guide you used and the one I linked referrer to another article both are based on, but the one I linked seems to be the preferred one to direct new users to in the #git IRC channel.