title: Check if pull needed in Git
body: <p>How do I check whether the remote repository has changed and I need to pull?</p>
  
  <p>Now I use this simple script:</p>
  
  <pre><code>git pull --dry-run | grep -q -v 'Already up-to-date.' &amp;&amp; changed=1
  </code></pre>
  
  <p>But it is rather heavy.</p>
  
  <p>Is there a better way? The ideal solution would check all the remote branches, and return names of the changed branches and the number of new commits in each one.</p>