Git command not found

gitrhel

I had to install git from source on RHEL. After installation the git command is shown to be in /usr/local/bin/git when trying the whereis command.This path is available in $PATH also.

When I type git it still says "Command not found."
How to resolve this?

EDIT : output of various commands

$type git
type: Command not found.

$which git
git: Command not found.

$ls -l /usr/local/bin/git
-rwxr-xr-x 112 root users 5851488 Mar 15 20:07 /usr/local/bin/git

$whereis git
git: /usr/local/bin/git

$echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

EDIT: It works now but do not know why

I disconnected the telnet connection and logged in again few minutes back and find that the git command works. I am not sure what caused it to start working. This is confusing.

Best Answer

From the error messages you're using (t)csh. It would help to mention it in your question, especially as you're showing $ as your prompt, and that's traditionally a Bourne prompt, not a csh prompt.

type is a builtin in Bourne-style shell. It doesn't exist in csh. When you run type git, it tells you that the type command is not found.

Many shells keep information about the location of commands in the search path in a cache. I don't know if any version of csh caches negative lookups, but it seems that yours does. Run the command rehash to refresh the cache. When you start a new shell instance, it has a fresh cache and so doesn't remember that git was not present earlier.

Related Question