Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
4  
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

2 Answers 2

up vote 12 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
/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
share|improve this answer

Your Answer

 
discard

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.