Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to update my git installation to the latest version. I'm having trouble getting rid of the old version, which the git command is still referencing:

$ git --version
git version

This is weird because:

$ which git


$ /usr/local/bin/git --version
git version 1.8.4

I didn't use MacPorts to install the old one. Any ideas?

share|improve this question
up vote 3 down vote accepted

Aliases will resolve first, so if you alias 'git' to someplace, then BASH will go to the alias location, which can be different from the first place that git appears on the PATH, which is what which git shows you.

share|improve this answer

Enter the following:

hash -r

or alternatively, close your Terminal session (completely, with Q) and then reopen it. I'm suspecting you've been using the same session for a long time, and the shell still has the old location of the git binary in its path hash (hence the name of the command). Rehashing (the -r option) or restarting the shell will clear everything out and reload it.

share|improve this answer
Tried that first thing. Didn't help. – No Surprises Oct 1 '13 at 3:48
that's strange - did you run hash -r or restart Terminal? – MattDMo Oct 1 '13 at 3:49
what shell are you using? – MattDMo Oct 1 '13 at 3:49
I had tried restarting the Terminal many times over the course of the last hour or so. I didn't know about hash -r. I'm using bash. – No Surprises Oct 1 '13 at 3:50
strange indeed... – MattDMo Oct 1 '13 at 3:51

I just went to each directory in my PATH and looked for the old version of git. I found it in ~/bin. Removed it and now I'm good to go. I still don't understand why which is finding the new one but the git command was finding the old one.

share|improve this answer
see my answer below... – MattDMo Oct 1 '13 at 3:48
Thanks. I did try that but it didn't help. I had to hunt down and remove the old one. Still confused though. – No Surprises Oct 1 '13 at 3:48
Is it possible you had aliased git to ~/bin/git ? – Kent Oct 1 '13 at 4:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .