多个已安装版本的 git - centos

Eog*_*anM 8 version centos git

我在一两年前手动安装了 git 1.6。我今天注意到 1.7 版本在 yum 中可用,并安装它(包 git-all)我现在得到以下输出:

[root@ovz5197 ~]# git --version
bash: /usr/local/bin/git: No such file or directory
[root@ovz5197 ~]# which git
/usr/bin/git
[root@ovz5197 ~]# /usr/bin/git --version
git version 1.7.4.1
[root@ovz5197 ~]# 
Run Code Online (Sandbox Code Playgroud)

知道为什么输出which似乎与上面的第一行矛盾吗?

Gil*_*il' 7

如果您在有gitbash 时已经从这个 bash 实例运行回来/usr/local/bin/git,它会记住缓存中的旧位置。运行hash -r以清除缓存。每个 bash 实例都有自己的缓存,因此新启动的 bash 实例会在正确的位置查找。

否则,您显然有一个 file /usr/local/bin/git,并且它是可执行的,但它不起作用,因为它的加载程序不在系统上。有关类似情况,请参阅在 64 位系统上运行 32 位二进制文​​件时获取“未找到”消息