54

Environment: Mac OSX 10.10. When I was trying to use gitk, it shows:

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

I think the reason is the old version of git. Here is some information, and I have already typed 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

What is this message: it's just not linked?

Furthermore, I check the path of git:

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

It should be in /usr/bin/local/git? How to fix it?

UPDATE

I figure it out, thank @TimCastelijns.

brew doctor said:

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

So, I typed:

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

Then I typed gitk, and it worked and the path changed to /usr/local/bin/git. However, when I want to check the version of git. It still showed the old version, why?

Coda-2:~ Coda$ git --version
git version 1.9.3 (Apple Git-50)
slm
  • 15,396
  • 12
  • 109
  • 124
rj487
  • 4,476
  • 6
  • 47
  • 88

3 Answers3

79

I just installed the latest version of git via homebrew on macos.

11:28 $ git --version
git version 2.25.0

It doesn't seem to have gitk and git gui so I noticed the answer for linux and tried to install the same package git-gui via homebrew and it worked.

brew install git-gui

Found the bug here.

I'm running macos 10.14.5 Mojave.

Clintm
  • 4,505
  • 3
  • 41
  • 54
  • 3
    It makes sense, git seems not to include the gitk in the standard package anymore. – Bruno Medeiros Feb 13 '20 at 01:41
  • 2
    It's even mentioned in the caveats after `brew install git` (or `brew info git`) now if you take a moment to read through: ```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.``` – peepa Jul 01 '20 at 12:22
  • 1
    `brew doctor` didn't find any issues, installing `git-gui` solved it for me. Running Catalina. – 3Gee Nov 11 '21 at 20:20
  • 1
    for Mac machine this was easy fix..worked for me – Samiksha Jagtap Jan 31 '22 at 06:42
55

Follow these steps to fix the issue:

  1. Check git version with git --version, and it may show old version.

  2. Update Homebrew with brew update.

  3. Install the latest version of Git from Homebrew with brew install git.

    (Note that if anything went wrong with the installation, the brew doctor command can be used. In my case, it told me to use brew link git.)

I can now use gitk.

Edric
  • 24,639
  • 13
  • 81
  • 91
rj487
  • 4,476
  • 6
  • 47
  • 88
5

Granted the OP is using Mac, a Linux user will find this link from Google and the accepted solution will not help.

On Linux, use your favourite package manager and install git-gui.

On RedHat-based systems, ex CentOS, do:

yum install -y git-gui

which will install the gitk dependency.

Done.

Shailen
  • 7,909
  • 3
  • 29
  • 37