title: git hook permission problem
body: <p>I've set my git working structure as follows (thanks to a recommendation in another question <a href="https://stackoverflow.com/questions/4394300/git-small-project-work">git : Small project work</a>)</p>
  
  <pre><code> /live/website
         |
         |
  /path/to/staging (bare)
    |          |
    |          |
  dev1        dev2
  </code></pre>
  
  <p>Currently, both dev1 and dev2, push the projects to the <code>/path/to/staging repo</code>. I have a hook in /path/to/staging, that automatically triggers a <code>git pull</code> from my  /live/website. This way, I have a working copy of files there.</p>
  
  <p>Also <code>/path/to/staging (bare)</code> was initialized with share=0777, so I know for a fact the share is not a problem. Also, I've CHMODded all files to 777 and set the stick bit as well.</p>
  
  <p>I've created the /live/website repo as <code>user : root</code>. However, I've created the repo in dev1 as <code>user : dev1</code>. I can make changes in dev1 fine, however when I try to push the repo from dev1, here's the problem I face:</p>
  
  <pre><code>error: Couldn't set refs/remotes/origin/master
  From /path/to/staging
   ! 8b4fddc2 .. e2a0b21  master     -&gt; origin/master  (unable to update local ref)
  To path/to/staging
     8c5fddc2  .. e2a0b21 master -&gt; master
  </code></pre>
  
  <p>And basically, I don't see the files transfer successfully to /live/website. I think this problem arises since I'm executing the code as <code>user : dev1</code>. However, when I browse to <code>/live/websit</code>e and do a <code>git pull</code> manually as <code>user : root</code>, it does successfully pull the changes made by dev1 and changes the working file.</p>
  
  <p>Can someone recommend if there is a way to work around this problem? Since it beats the purpose of the automatic hook ...</p>
  
  <p>Something else that I thought of doing was in the hook, I was thinking of changing the user:</p>
  
  <pre><code>su root
  password
  </code></pre>
  
  <p>However, when it executes, I don't think I'm entering the password at the prompt, since the error message I receive is :</p>
  
  <pre><code>hooks/post-receive: line 18: password: command not found
  </code></pre>
  
  <hr>
  
  <p>EDIT ,</p>
  
  <p>Also, can someone suggest a way to go back from a push? And get the previous state of files?</p>