找不到 git 命令

Man*_*noj 5 rhel git

我必须在 RHEL 上从源代码安装 git。安装后,/usr/local/bin/git在尝试whereis命令时显示 git 命令。 此路径也可用$PATH

当我输入 git 时,它仍然显示“找不到命令”。如何解决这个问题?

编辑:各种命令的输出

$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
Run Code Online (Sandbox Code Playgroud)

编辑:它现在有效,但不知道为什么

我断开了 telnet 连接并在几分钟前再次登录,发现 git 命令有效。我不确定是什么导致它开始工作。这令人困惑。

Gil*_*il' 3

从错误消息来看,您正在使用 (t)csh。在您的问题中提及它会有所帮助,特别是当您显示$为提示符时,这通常是 Bourne 提示符,而不是 csh 提示符。

type是 Bourne 风格的内置 shell。它在csh 中不存在。当您运行时,它会告诉您未找到type git该命令。type

许多 shell 将有关搜索路径中的命令位置的信息保存在缓存中。我不知道是否有任何版本的 csh 缓存否定查找,但似乎你的版本确实如此。运行命令rehash刷新缓存。当您启动一个新的 shell 实例时,它有一个新的缓存,因此不记得git之前不存在。