title: Git log to get commits only for a specific branch
body: <p>I want to list all commits that are only part of a specific branch.</p>
  
  <p>With the following, it lists all the commits from the branch, but also from the parent (master)</p>
  
  <pre><code>git log mybranch
  </code></pre>
  
  <p>The other option I found, was to exclude the commits reachable by master and gives me what I want, BUT I would like to avoid the need of knowing the other branches names.</p>
  
  <pre><code>git log mybranch --not master
  </code></pre>
  
  <p>I was trying to use <code>git for-each-ref</code>, but it is also listing mybranch so actually it is excluding all:</p>
  
  <pre><code>git log mybranch --not $(git for-each-ref --format '^%(refname:short)' refs/heads/)
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I'm testing a new option that I found a while ago, and till now seems that this could be what I was looking for:</p>
  
  <pre><code>git log --walk-reflogs mybranch
  </code></pre>
  
  <p><strong>Update (2013-02-13T15:08):</strong></p>
  
  <p>The --walk-reflogs option is good, but I checked that there is an expiration for reflogs (default 90 days, <a href="http://www.kernel.org/pub/software/scm/git/docs/git-gc.html" rel="noreferrer">gc.reflogExpire</a>).</p>
  
  <p>I think I found the answer I was looking for:</p>
  
  <pre><code>git log mybranch --not $(git for-each-ref --format='%(refname)' refs/heads/ | grep -v "refs/heads/mybranch")
  </code></pre>
  
  <p>I'm just removing the current branch from list of branches available and using that list to be excluded from the log. This way I only get the commits that are <strong>only reached by mybranch</strong>.</p>