title: String comparison not working in PowerShell function - what am I doing wrong?
body: <p>I'm trying to make an alias of <code>git commit</code> which also logs the message into a separate text file. However, if <code>git commit</code> returns <code>"nothing to commit (working directory clean)"</code>, it should NOT log anything to the separate file.</p>
  
  <p>Here's my code. The <code>git commit</code> alias works; the output to file works. However, it logs the message no matter what gets returned out of <code>git commit</code>.</p>
  
  <pre><code>function git-commit-and-log($msg)
  {
      $q = git commit -a -m $msg
      $q
      if ($q –notcontains "nothing to commit") {
          $msg | Out-File w:\log.txt -Append
      }
  }
  
  Set-Alias -Name gcomm -Value git-commit-and-log
  </code></pre>
  
  <p>I'm using PowerShell 3.</p>