I would use a post-update hook that will pull changes into the webroot and perhaps also run some other commands like clearing the caches etc.
First you need to create a bare repository:
mkdir /var/git/<repo-production.git>
cd /var/git/<repo-production.git>
git init --bare
cp hooks/post-update.sample hooks/post-update
chmod +x hooks/post-update
You then need to modifiy your post-update to something like:
#!/bin/sh
cd /var/www/<your_www_root> || exit
unset GIT_DIR
git pull hub master
# if you have drush installed you clear caches here
# drush cc all
exec git update-server-info
Then you need to clone out the repository in your webroot:
cd /var/www
git clone /var/git/<repo-production.git> <your_www_root>
cd <your_www_root>
git remote rename origin hub
Then on your local machine you add the remote like this:
git remote add production ssh://[email protected]:/var/git/<repo-production.git>
Of course you need to change the above to match your own username, hostname and path to your repository.
You should now be able to push changes to the remote repository, than in turn will deploy any changes into the webroot.
git push production
Notice that you can setup another bare repository for your staging environment and modify the above so it checkout the code to a different location. A nice approach would then be to add it using git remote add staging <path_to_staging_repoistory>
. Done this you are able to push your code either to production
using git push production
or to staging
using git push staging
.