title: How to get push notifications from a remote git repository in real time?
body: <p>I have a remote repository (bitbucket), a server repository (linux) and many local repositories (developers).</p>
  
  <p>I want the server to be notified if some developer changes a branch in the remote.</p>
  
  <p>Until now i tried using a bash script declared in cron in the server but the minimal resolution is 1 minute, so to adapt it for real-time seems to be very tricky. However, my approach is this:</p>
  
  <pre><code>path=/some/dir/
  
  # something new in remote
  if git fetch origin &amp;&amp; [ `git rev-list HEAD...origin/master --count` != 0 ]
  then
      echo 'Remote repository has changed. Pull needed' &amp;&gt;&gt;$path/git-backup.log
      echo $d &gt;&gt; $path/git-backup.log
      git merge origin/master &amp;&gt;&gt;$path/git-backup.log
  fi
  </code></pre>