Server Fault is a question and answer site for system and network administrators. 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 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
$ which 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?

share|improve this question
what shows whereis git? and less probable, what shows type git? – hmontoliu Aug 5 '11 at 18:24
Why not simply uninstall the version you got from apt-get if you don't want it? – Zoredache Aug 5 '11 at 18:24
Did you remove the binary version from apt-get? – quanta Aug 5 '11 at 18:25
@hmontoliu useful commands! I didn't know about either of those. whereis git: git: /usr/bin/git /usr/local/bin/git /usr/share/man/man1/git.1.gz. type git: git is hashed (/usr/bin/git). What does "git is hashed" mean? – Josh Bleecher Snyder Aug 5 '11 at 18:30
@ Zoredache, quanta: Yep, that seems like a sensible thing to do. I just like to understand what's going on, in addition to fixing the problem. – Josh Bleecher Snyder Aug 5 '11 at 18:32
up vote 13 down vote accepted

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

share|improve this answer
That was it! Thanks, for both the solution and the clear explanation. – Josh Bleecher Snyder Aug 5 '11 at 19:07

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
$ git --version
This is not the git you are looking for --version
$ /usr/bin/git --version
git version
$ 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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.