Using git to fetch changes from testing version to live website I am maintaining and developing a Drupal website and have a testing/development version of the site in a subfolder of drupal instalation. I started to learn git and I am wondering about how could I use it in my development process. I came up with following solution:

Make a git repository for live site and clone it in the test subfolder (which will be added into live site's .gitignore file). Make some development in the test directory, test it and when I'm satisfied, switch to the live site repository, fetch and merge the changes.

Since I am a newbie to git, I'd like to know if this approach can be succesfully used, or if not, which aspects should I change/or come up with completely different solution.
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/&lt;repo-production.git&gt;
cd /var/git/&lt;repo-production.git&gt;
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/&lt;your_www_root&gt; || 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/&lt;repo-production.git&gt; &lt;your_www_root&gt;
cd &lt;your_www_root&gt;
git remote rename origin hub


Then on your local machine you add the remote like this:

git remote add production ssh://root@example.com:/var/git/&lt;repo-production.git&gt;


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 &lt;path_to_staging_repoistory&gt;. Done this you are able to push your code either to production using git push production or to staging using git push staging.