title: How to reference the most recent git commit whose commit message contains a certain word?
body: <p>I want to do</p>
  
  <pre><code>$ git log - 5
  *  adc24eb Jim &gt; (HEAD -&gt; demo) fixup
  *  cb6a1a7 Jim &gt; fixup
  *  60d7150 Jim &gt; (origin/demo) Much prettier demo output.
  *  a8112c2 Michael &gt; Complete ugly demo:
  </code></pre>
  
  <p>and then do some operations with <code>a8112c2</code>.  Rather than referencing that commit by SHA, as in</p>
  
  <pre><code>$ git &lt;command&gt; a8112c2
  </code></pre>
  
  <p>, I want to type things like</p>
  
  <pre><code>$ git rebase -i %ugly
  $ git show %ugly
  $ git reset --soft %ugly
  </code></pre>
  
  <p>where %ugly is expanded by git to the SHA of the most recent commit whose commit message first line contains the word "ugly".</p>
  
  <p><strong>What's the magic syntax for this?</strong></p>
  
  <p>I'm 99% sure this has been asked before and I cannot find it.</p>