Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set up a Git hook so that after pushing to ssh://peter@foo.com/~/bar.com.git, it will go to ~/bar.com and do a git pull?
    text
    copied!<p>I was advised to set up on a remote server</p> <pre><code>foo.com/~/bar.com # live webpage content foo.com/~/bar.com.git # a bare repo </code></pre> <p>so, from my local machine, I can do a </p> <pre><code>git push </code></pre> <p>and it will push to <code>foo.com/~/bar.com.git</code> on the remote machine (the full path is <code>ssh://peter@www.foo.com/~/bar.com.git</code></p> <p>How can a <strong>hook</strong> be added, so that after the push, the remote server will <code>cd ~/bar.com</code> and do a <code>git pull</code> so that all content is updated (the same as the local machine)? (no need to run <code>git update</code> like for Mercurial?)</p> <p>(this is related to <a href="https://stackoverflow.com/questions/5703324/cannot-git-clone-a-folder-on-a-server-and-then-edit-and-git-push">Cannot git clone a folder on a server and then edit and git push?</a> right now I can ssh to <code>foo.com</code> and <code>cd ~/bar.com</code> and wait there and do a <code>git pull</code> whenever after a <code>git push</code> from the local machine, but it'd be nice to have it done automatically)</p> <p><strong>Update</strong>: please only post an answer if you know specific details and how to do it. If you google and post the first or second google result here, it is not going to help.</p> <p><strong>Update 2</strong>: I went to <code>~/bar.com.git/hooks</code> and add a new file <code>post-receive</code> with the content:</p> <pre><code>#!/bin/bash cd ~/bar.com git pull ../bar.com.git master </code></pre> <p>and also <code>chmod 755 post-receive</code>, and if I edit a file on the local machine, and then <code>git com -m "ok"</code> and <code>git push</code>, it doesn't make the change go into the remote machine's folder <code>~/bar.com</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload