git --version 命令returns 与实际安装结果不同
git --version command returns different result from what's actually installed
试图用自制软件更新我的 git,但我遇到了这个问题:
MBP:GitHub_Tutorial nasdas$ brew install git
Warning: git 2.21.0 is already installed and up-to-date
To reinstall 2.21.0, run `brew reinstall git`
MBP:GitHub_Tutorial nasdas$ git --version
git version 2.17.2 (Apple Git-113)
推测您已经安装了两个版本,彼此独立。
使用 type git
或 which git
来查看您运行宁哪一个。大概是/usr/bin/git
。 brew安装的大概是/usr/local/bin/git
。更改 $PATH
(或 $path
或 shell 使用的任何内容)将 /usr/local/bin
放在 /usr/bin
之前,以便 git
将 运行新的而不是旧的,或者使用 /usr/local/bin/git
到 运行 新的。
(并且,作为 ,请注意,您可能必须在各种 shell 中 运行 hash -r
,以便在 shell 中安装某些内容后让他们再次检查 /usr/local/bin
,如果他们已经确定 git
意味着 /usr/bin/git
,即使 $PATH
之前有 /usr/local/bin
。在 csh/tcsh 中,这是 rehash
而不是 hash -r
.)
(事实证明是哈希问题——你的 shell 早些时候决定 git
意味着旧的。再次登录也可以清除此类问题,但那是痛!)
试图用自制软件更新我的 git,但我遇到了这个问题:
MBP:GitHub_Tutorial nasdas$ brew install git
Warning: git 2.21.0 is already installed and up-to-date
To reinstall 2.21.0, run `brew reinstall git`
MBP:GitHub_Tutorial nasdas$ git --version
git version 2.17.2 (Apple Git-113)
推测您已经安装了两个版本,彼此独立。
使用 type git
或 which git
来查看您运行宁哪一个。大概是/usr/bin/git
。 brew安装的大概是/usr/local/bin/git
。更改 $PATH
(或 $path
或 shell 使用的任何内容)将 /usr/local/bin
放在 /usr/bin
之前,以便 git
将 运行新的而不是旧的,或者使用 /usr/local/bin/git
到 运行 新的。
(并且,作为 hash -r
,以便在 shell 中安装某些内容后让他们再次检查 /usr/local/bin
,如果他们已经确定 git
意味着 /usr/bin/git
,即使 $PATH
之前有 /usr/local/bin
。在 csh/tcsh 中,这是 rehash
而不是 hash -r
.)
(事实证明是哈希问题——你的 shell 早些时候决定 git
意味着旧的。再次登录也可以清除此类问题,但那是痛!)