4

I installed git via apt-get, but found that the version was hopelessly outdated, so I then installed git from source. The end result is rather puzzling:

$ git --version
git version 1.7.0.4
$ which git
/usr/local/bin/git
$ /usr/local/bin/git --version
git version 1.7.6

It appears that which is lying to me...which seems unlikely. What is actually going on here, and how can I get a bare call to git to run the correct version?

2 Answers2

14

which is telling the truth. Your shell is lying to you.

git is hashed (/usr/bin/git)

means that your shell has cached this location of "git" and is using the cached path rather than searching $PATH again. Use hash -r to clear the cache and make the shell search $PATH for the new git at /usr/local/bin/git

DerfK
  • 19,493
  • 2
  • 38
  • 54
0

Did you set up an alias for git in your shell?

$ alias git="/bin/echo This is not the git you are looking for"
$ which git
/usr/bin/git
$ git --version
This is not the git you are looking for --version
$ /usr/bin/git --version
git version 1.7.4.1
$ type git
git is aliased to `/bin/echo This is not the git you are looking for'
$ unalias git
$ type git
git is /usr/bin/git
$ git --version
git version 1.7.4.1
sciurus
  • 12,678
  • 2
  • 31
  • 49