title: Why or how is it that is my path is not being respected MacOSX?
body: <p>How is it possible that the binary executed 'by default' -- ie. the first one found in my path, as returned by the <code>which</code> command, is in fact not the binary actually being executed by default?  (I'm running Mac OS X 10.5 on a 2008 MacBook Pro.)</p>
  
  <p>I just installed the latest version of git by running <code>brew install git</code>  </p>
  
  <p>It installed the new version in a location <em>higher or earlier</em> in my path than the old binary.  However, the new version is not executed by default.  It's as if the shell had cached the location of the binary before I installed the new one - but the <code>which</code> command parses the path every time it runs.    </p>
  
  <p>I'd like to understand what's going on here and learn how to flush the 'cache' without having to log out or restart the machine.  This is what I'm seeing:</p>
  
  <pre><code>which git
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>/usr/local/bin/git
  </code></pre>
  
  <p>while</p>
  
  <pre><code>git --version
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>git version 1.6.5
  </code></pre>
  
  <p>but</p>
  
  <pre><code>/usr/local/bin/git --version
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>git version 1.7.7
  </code></pre>
  
  <p>Checking further, </p>
  
  <pre><code>which -a git
  </code></pre>
  
  <p>returns </p>
  
  <pre><code>/usr/local/bin/git
  /usr/local/git/bin/git
  /usr/local/bin/git
  /usr/local/git/bin/git
  /usr/local/bin/git
  /usr/local/git/bin/git
  </code></pre>
  
  <p>(yeah - there's some redundancy in my path setup.)</p>
  
  <pre><code>/usr/local/git/bin/git --version
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>git version 1.6.5
  </code></pre>
  
  <p><em>UPDATE</em> -- here's the answer bash hashes. (<em>from:</em> <a href="https://stackoverflow.com/questions/7746240/in-bash-which-gives-an-incorrect-path-python-versions">In bash, &quot;which&quot; gives an incorrect path - Python versions</a> )</p>
  
  <pre><code>type git
  
  git is hashed (/usr/local/git/bin/git)
  
  $ hash -d git
  
  $ type git
  git is /usr/local/bin/git
  
  $ which git
  /usr/local/bin/git
  
  git --version
  git version 1.7.7
  </code></pre>