【问题标题】:gitk: command not foundgitk:找不到命令
【发布时间】:2015-07-23 13:53:57
【问题描述】:

环境:Mac OSX 10.10。当我尝试使用gitk 时,它显示:

Coda-2:~ Coda$ gitk
-bash: gitk: command not found

我认为原因是git 的旧版本。这是一些信息,我已经输入了brew update

Coda-2:~ Coda$ git --version
git version 1.9.3 (Apple Git-50)
Coda-2:~ Coda$ brew install git 
Warning: git-2.4.0 already installed, it's just not linked

这条消息是什么:it's just not linked

另外,我查看git的路径:

Coda-2:~ Coda$ which git
/usr/bin/git

应该在/usr/bin/local/git?如何解决?

更新

我明白了,谢谢@TimCastelijns。

brew doctor 说:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:

    git

所以,我输入了:

Coda-2:~ Coda$ brew link git
Linking /usr/local/Cellar/git/2.4.0... 220 symlinks created

然后我输入了gitk,它成功了,路径更改为/usr/local/bin/git。但是,当我想检查git 的版本时。它仍然显示旧版本,为什么?

Coda-2:~ Coda$ git --version
git version 1.9.3 (Apple Git-50)

【问题讨论】:

  • 什么是未链接的?表示如果您输入git,它将使用旧安装,而不是新安装
  • 哈哈!我现在知道了!谢谢,我知道了!
  • 但是,我链接了新版本,gitk 也可以,为什么当我输入 which git 时它仍然显示旧版本的 git
  • 使用type,而不是which
  • 对不起,我添加了错误的命令。我的意思是我输入 git --version ,它不应该显示 git version 2.4 吗?但它告诉我git version 1.9.3

标签: git gitk


【解决方案1】:

按照以下步骤解决问题:

  1. git --version检查git版本,可能会显示旧版本。

  2. 使用 brew update 更新 Homebrew。

  3. 使用 brew install git 从 Homebrew 安装最新版本的 Git。

    (请注意,如果安装出现任何问题,可以使用brew doctor 命令。就我而言,它告诉我使用brew link git。)

我现在可以使用gitk

【讨论】:

  • 不错的答案,但您不应该将 brew 与 sudo 一起使用。
  • 如果有人在使用brew link git 时遇到问题(即所有权问题),请查看此stackoverflow.com/questions/26647412/…
  • 谢谢。 TLDR 版本命令 brew install git 对我来说就足够了。
  • 当问题是关于 gitk 时为什么要 gitx?
【解决方案2】:

我刚刚在 macos 上通过 homebrew 安装了最新版本的 git。

11:28 $ git --version
git version 2.25.0

它似乎没有 gitk 和 git gui,所以我注意到了 linux 的答案,并尝试通过自制软件安装相同的包 git-gui,它成功了。

brew install git-gui

发现错误here

我正在运行 macos 10.14.5 Mojave。

【讨论】:

  • 说得有道理,git似乎不再在标准包中包含gitk了。
  • 如果您花点时间阅读,现在brew install git(或brew info git)之后的警告中甚至会提到它:From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rb ==> Dependencies Required: gettext ✔, pcre2 ✔ ==> Options --HEAD Install HEAD version ==> Caveats The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula.
  • brew doctor 没有发现任何问题,安装git-gui 为我解决了它。运行卡特琳娜。
【解决方案3】:

尽管 OP 使用的是 Mac,Linux 用户会从 Google 找到此链接,而接受的解决方案将无济于事。

在 Linux 上,使用您最喜欢的包管理器并安装 git-gui

在基于 RedHat 的系统上,例如 CentOS,执行:

yum install -y git-gui

这将安装 gitk 依赖项。

完成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-01
    • 2012-08-11
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    相关资源
    最近更新 更多