I found this script on this site and it seems to work quite well.
- Copy over your .git directory to your web server
-
On your local copy, modify your .git/config file and add your web server as a remote:
[remote "production"] url = username@webserver:/path/to/htdocs/.git
-
On the server, replace .git/hooks/post-update with this file (in the answer below)
-
Add execute access to the file (again, on the server):
chmod +x .git/hooks/post-update
-
Now, just locally push to your web server and it should automatically update the working copy:
git push production