title: Howto sync database with git and git hooks and howto debug if it doesn't work
body: <p>On OS: Ubuntu 12.04  </p>
  
  <p>I've got a drupal deployment (live website) and a staging environment (test website) on my server. Each time I pull changes from my staging website I want to synchronize the database automatically, as instructed here: <a href="http://ben.kulbertis.org/2011/10/synchronizing-a-mysql-database-with-git-and-git-hooks/" rel="nofollow">http://ben.kulbertis.org/2011/10/synchronizing-a-mysql-database-with-git-and-git-hooks/</a></p>
  
  <p>The setup I use is exactly the same (with settings and paths according to my setup of course). </p>
  
  <p><strong>Quote from the website:</strong></p>
  
  <blockquote>
    <p>Let’s start with pre-commit. The pre-commit hook will run a script directly before a commit is executed. To edit your pre-commit hook:</p>
  
  <pre><code>[your editor] /path/to/your/repo/.git/hooks/pre-commit
  </code></pre>
    
    <p>Now, lets write the pre-commit script. We are going to tell the system to dump our MySQL database to our git repository and add it to be committed.</p>
  
  <pre><code>#!/bin/sh
  mysqldump -u [mysql user] -p[mysql password] --skip-extended-insert [database] &gt; /path/to&gt; /your/repo/[database].sql
  cd /path/to/your/repo
  git add [database].sql
  </code></pre>
    
    <p>Now, lets write the post-merge script. We are going to tell the system to restore the MySQL dump to the local database for the latest changes. Edit the post-merge hook with:</p>
  
  <pre><code>[your editor] /path/to/your/repo/.git/hooks/post-merge
  </code></pre>
    
    <p>And write:</p>
  
  <pre><code>#!/bin/sh
  mysql -u [mysql user] -p[mysql password] [database] &lt; /path/to/your/repo/[database].sql
  </code></pre>
  </blockquote>
  
  <p>But when I do a commit and then a pull, nothing seems to happen. The post-merge and pre-commit hooks reside in my hooks dir of the deployment repository from which I conduct the commit and pull. Both have execution rights: <code>chmod +x /path/to/hook</code></p>
  
  <p>I have tested the commands I have placed in the hooks. They should work correctly.</p>
  
  <p>Any way to debug what's wrong?</p>