Install gitk on Mac

Question

How can I install gitk on a Mac?

From their official website, it seems gitk comes with Git, but the version of my Git (git version 1.7.12.4 (Apple Git-37)) does not come with gitk.

brew install gitk does not work for gitk.

Version information (copied from comments):

Answer

Correct, the 1.7.12.4 (Apple Git-37) does not come with gitk. You can install a more recent version of Git + git-ui as a separate formula by using Homebrew (executable brew). More thorough instructions are located on The fastest and easiest way to install Ruby on a Mac in 2022 (see this commit extracting git-gui/gitk into its own formula: git-gui: split from git formula.)

Run the following commands at the terminal:

brew update
brew install git
brew install git-gui

If you get an error indicating it could not link Git, then you may need to change permissions/owners of the files it mentions.

Once completed, run:

type -a git

And make sure it shows:

/usr/local/bin/git

If it does not, run:

brew doctor

And make the path change to put /usr/local/bin earlier in the path. Now, gitk should be on your path (along with an updated version of Git).

How can I recover a lost commit in Git?

What does cherry-picking a commit with Git mean?