[git] Install gitk on Mac

Does anyone know how to install gitk on 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 info (copied from comments):

  • OS X 10.8.2 (12C2034) "Mountain Lion"
  • XCode Version 4.6 (4H127)

This question is related to git macos osx-mountain-lion gitk

The answer is


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 brew. More thorough instructions located here: http://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/ (see this commit extracting git-gui/gitk into its own formula: https://github.com/Homebrew/homebrew-core/commit/dfa3ccf1e7d3901e371b5140b935839ba9d8b706)

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).


You can also get gitk with the git from MacPorts.

sudo port install git

There are two ways to fix this:

  1. Unix Way (simple and recommended)
  2. Homebrew Way

1. Unix Way: In 4 simple steps

  1. Execute which git in the terminal to know the location of your git executable. Open that directory & locate gitk inside the bin folder. Copy the path --- typically /usr/local/git/bin
  2. Edit your ~/.bash_profile to add the location of local git & gitk in the paths or, simply copy-pasta from the sample written below.

Sample bash_profile:

# enabling gitk
export PATH=/usr/local/git/bin:$PATH

If you don't have a bash_profile want to learn how to create one, then click here.

  1. This step is relevant if you're using El Capitan or higher & you run into an unknown color name “lime” error. Locate gitk executable (typically at /usr/local/bin/gitk), take a backup & open it in a text editor. Find all occurences of lime in the file & replace them with "#99FF00".
  2. Reload bash: source ~/.bash_profile

Now, run gitk


2. HomeBrew way

Updates - If you do not have homebrew on your mac, get it installed first. It may require sudo privileges.

  • brew update
  • brew doctor
  • brew link git
  • added /usr/local/Cellar/git/2.4.0/bin to path & then reload bash & run gitk
  • No luck yet? Proceed further.
  • Run which git & observe if git is still linked to /usr/bin/git
  • If yes, then open the directory & locate the was a binary executable.
  • Take its backup, may be save with a name git.bak & delete the original file
  • Reload the terminal - source ~/.bash_profile

I had the same problem on Mac 10.7.5 with git version 1.7.12.4

When I ran gitk I got an error:

"Error in startup script: expected version number but got "Git-37)"
    while executing
"package vcompare $git_version "1.6.6.2""
    invoked from within
"if {[package vcompare $git_version "1.6.6.2"] >= 0} {
    set show_notes "--show-notes"
}"
    (file "/usr/bin/gitk" line 11587)

When I looked at the code in gitk I saw the line that sets the version.

set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .]

This somehow parsed the git version results to Git-37 instead of 1.7.12.4

I just replaced the git_version line with:

set git_version "1.7.12.4"

For Mojave users, I found this page very useful, particularly this suggestion:

/usr/bin/wish $(which gitk)

...without that, the window did not display correctly!


As of macOS Catalina 10.15.6, I run:

brew install git
brew install git-gui

and it worked for me.


If you happen to already have Fink installed, this worked for me on Yosemite / OS X 10.10.5:

fink install git

Note that as a side effect, other git commands are also using the newer git version (2.5.1) installed by Fink, rather than the version from Apple (2.3.2), which is still there but preempted by my $PATH.


If, like me, you have SourceTree installed, but want to use gitk as well, you can use the version that comes with SourceTree's embedded version of git.

SourceTree's version of git (and thus gitk) is here:

For Windows:

C:\Users\User\AppData\Local\Atlassian\SourceTree\git_local\bin\git.exe

or

%USERPROFILE%\AppData\Local\Atlassian\SourceTree\git_local\bin

For Mac:

/Applications/SourceTree.app/Contents/Resources/git_local/bin

In that directory, you'll find a gitk executable.

Thanks to @Adrian for the comment which alerted me to this. I thought it was worth posting as an answer in its own right.


I had the same issue. I installed gitx instead.

You can install gitx from here.

http://rowanj.github.io/gitx/

Download the package and install it. After that open the gitk from spotlight search, goto the top left corner. Click on GitX and enable the terminal usage.

Goto your repo and simply type:

$ gitx --all

It will open the Gui.

User manual: http://gitx.frim.nl/user_manual.html


I just had the same problem and solved it as follows:

  1. Download the official git package for Mac from http://git-scm.com/download/mac
  2. Install the package. This places all the binaries in /usr/local/git/bin.
  3. Optionally run the included script to make gitk accessible outside of terminals
  4. Either add /usr/local/git/bin to your PATH or use an alias (alias gitk='/usr/local/git/bin/gitk')

First you need to check which version of git you are running, the one installed with brew should be running on /usr/local/bin/git , you can verify this from a terminal using:

which git

In case git shows up on a different directory you need to run this from a terminal to add it to your path:

echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

After that you can close and open again your terminal or just run:

source ~/.bash_profile

And voila! In case you are running on OSX Mavericks you might need to install XQuartz.


Git Mac version comes without gitk but if you do brew install git you get instant access to gitk.

I'm using MAC sierra 10.12.5

Edit: This doesn´t work anymore, you must install brew install git-gui


If you already have git installed via homebrew, you can just do upgrade:

$ type -a git
/usr/bin/git
$ brew upgrade git
$ type -a git
/usr/local/bin/git

The one at local/bin will have gitk


What I ended up doing was: brew info git

Which gave me info that git was cloned into: /usr/local/Cellar/git/1.9.0

So I just added: /usr/local/Cellar/git/1.9.0/bin to the beginning of my PATH env variable.

Note: I don't know how to use homebrew... just want to get going quickly as I have other things to do... this basically gets gitk running for me so I'm sticking to it for now. (probably not the way to work with homebrew though).


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to osx-mountain-lion

Maven not found in Mac OSX mavericks Install gitk on Mac Error Installing Homebrew - Brew Command Not Found What is the "Illegal Instruction: 4" error and why does "-mmacosx-version-min=10.x" fix it? Socket File "/var/pgsql_socket/.s.PGSQL.5432" Missing In Mountain Lion (OS X Server)

Examples related to gitk

Install gitk on Mac Viewing full version tree in git