335

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mingyu
  • 31,751
  • 14
  • 55
  • 60
  • 1
    what version of osx are you using? On 10.8.4 I have `git version 1.8.2.1 (Apple Git-45)` which includes `gitk` – foundry Jul 10 '13 at 23:35
  • Have you installed XCode? – Matt Ball Jul 10 '13 at 23:35
  • I installed XCode Version `4.6 (4H127)` and Mac Version `OS X 10.8.2 (12C2034)` – Mingyu Jul 10 '13 at 23:42
  • 1
    There's roughly a bajillion Git tools that work on OS X, why do you need `gitk` specifically? Also, `gitk` is included with Homebrew git. – millimoose Jul 10 '13 at 23:47
  • Thanks @millimoose! Could you please recommend a couple similar tools? – Mingyu Jul 10 '13 at 23:50
  • 1
    @Mingyu: http://www.sourcetreeapp.com/, for one. – fjarri Jul 11 '13 at 00:19
  • Thanks for everyone's comments, and I installed SourceTree, which seems to be a great git client on Mac. – Mingyu Jul 11 '13 at 00:44
  • 2
    GitX is a pretty nice Git client. I miss it on Linux – rcomblen Jul 11 '13 at 06:44
  • http://git-scm.com/download/mac download this and install for gitk on macos – Daniel Bo Oct 10 '14 at 12:52
  • 1
    If you installed SourceTree ... it comes with it's own packed-in copy of `git` - and it's a build that has `gitk` in it, so you can create an alias for it and just use it. – Adrian Oct 16 '18 at 10:49
  • And here's where to find SourceTree's version of git which includes `gitk` as @Adrian mentioned: https://confluence.atlassian.com/sourcetreekb/using-embedded-git-or-system-git-in-sourcetree-785323587.html (see "SourceTree file path for Embedded Git") – Sam Feb 24 '20 at 14:39

15 Answers15

464

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jenna Pederson
  • 5,656
  • 1
  • 19
  • 20
  • 1
    I installed git 1.8.3.4 to use brew. But gitk has Bug. If you check out branch and type `gitk --all`, unstaged local branch is visible. After you type git status, unstaged local branch is unvisible. Does anyone experience it? – pebble8888 Aug 07 '13 at 00:42
  • 9
    I did all the update described above, but the version of git didn't change - I must have already had the most recent version. BUT now I suddenly have gitk! hurray – Kuba Jul 04 '14 at 09:03
  • 1
    Yep same with @Kuba I mysteriously now have gitk! – relipse Dec 09 '16 at 18:57
  • 2
    It might be necessary to restart the terminal session. – veksen Feb 23 '17 at 13:02
  • @giovannipds what was the problem? – volvox Jul 19 '18 at 09:14
  • @volvox path was not changing to `/usr/local/bin`, the latest git was installed but not being used and I didn't know to do that manually. I followed what @Leo explained here https://stackoverflow.com/a/18496039/842768 and installing Git again it has installed where it needed. – giovannipds Jul 22 '18 at 02:32
  • What if it's `/usr/bin/git`? – mrgloom Oct 07 '19 at 14:46
  • Even more recent versions of git that comes with MacOS Mojave does not come with gitk: `git version 2.20.1 (Apple Git-117)`. `brew install git` will install gitk. – wisbucky Nov 15 '19 at 18:25
  • The even more recent formula for `git` has extracted the UI tools and moved them into its own formula: `brew install git-gui` – Blacklight Jan 28 '20 at 13:54
  • Since I already had git installed, there was an error when creating the links on my initial install. I ran `brew link --overwrite git-gui` to force it to use the new one and everything works great now. – Michiel Bugher Jan 04 '21 at 20:35
  • And on Mac M1: arch -arm64 brew install git-gui instead of brew install git-gui – Chris Neve Jun 21 '21 at 13:56
  • works for me as of july 2023 – Phil Jul 31 '23 at 18:02
45

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

I'm using macOS v10.12.5 (Sierra).

But this stopped working. You must install brew install git-gui

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lionel M
  • 451
  • 4
  • 2
28

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 folder /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')
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Leo
  • 2,328
  • 2
  • 21
  • 41
27

As of macOS v10.15.6 (Catalina), I run:

brew install git
brew install git-gui

And it worked for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andre Ravazzi
  • 611
  • 7
  • 10
24

If you already have Git installed via Homebrew, you can just do upgrade:

type -a git
brew upgrade git
type -a git

Output

/usr/bin/git
/usr/local/bin/git

The one at local/bin will have gitk.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
aris
  • 22,725
  • 1
  • 29
  • 33
  • 3
    This should be the accepted answer. Also, if you have been using the system git that comes with Mac OS X, the sequence to do a new install of git via homebrew would instead be: `brew install git && which git` which (no pun intended!) should give you the output `/usr/local/bin/git` ... Note: I would also *highly* recommend updating and doctoring first, as in: `brew update ; brew doctor && brew install git && which git` -or- `brew update ; brew doctor && brew upgrade git && which git` instead... to get the expected `/usr/local/bin/git` output (from the `which` command). – likethesky Sep 10 '14 at 20:54
  • 1
    @giovannipds - do ***brew install git*** .you probably have older version of Git. – yantaq Aug 20 '18 at 19:56
17

I had the same issue. I installed GitX instead.

You can install GitX from here:

https://gitx.github.io/

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

Go to your repository and simply type:

gitx --all

It will open the GUI.

ADTC
  • 8,999
  • 5
  • 68
  • 93
Abhi
  • 3,361
  • 2
  • 33
  • 38
9

There are two ways to fix this:

  1. The Unix way (simple and recommended)
  2. The Homebrew way

1. Unix Way: In four 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 file to add the location of local git & gitk in the paths or, simply copy-paste 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 file and want to learn how to create one, then click here.

  1. This step is relevant if you're using OS X v10.11 (El Capitan) or higher, and 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 occurrences 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, reload Bash, and run gitk
  • No luck yet? Proceed further.
  • Run which git and observe if Git is still linked to /usr/bin/git
  • If yes, then open the directory and locate the was a binary executable.
  • Take its backup. It may be save with a name git.bak and delete the original file
  • Reload the terminal - source ~/.bash_profile
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
DDM
  • 1,099
  • 15
  • 21
  • 3
    brew should NOT need sudo privileges. The brew installation procedure itself needs sudo, but it then opens permissions on /usr/local so that after that you wont need sudo. If you need sudo, either you're choosing that you want brew to only work with sudo (totally understandable decision), or you've missed a step in the installation procedure. – Hugh Perkins May 21 '20 at 12:56
  • Yes, I'm aware of that. TBH `gitk` not working is a really annoying problem & failing to launch it because they forgot to `sudo` at some random step is the last thing I'd wished anyone reading this ever faced. I wrote it to play it safe (tho, sudo isn't). – DDM Jul 13 '20 at 21:11
4

You can also get gitk with the git from MacPorts.

sudo port install git
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
chrish
  • 2,352
  • 1
  • 17
  • 32
4

For macOS v10.14 (Mojave) users, I found this page very useful, particularly this suggestion:

/usr/bin/wish $(which gitk)

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Stuart Berg
  • 17,026
  • 12
  • 67
  • 99
2

I ended up doing 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 environment variable.

Note: I don't know how to use Homebrew... I 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 (it is probably not the way to work with Homebrew though).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
justin
  • 3,357
  • 1
  • 23
  • 28
2

If you happen to already have Fink installed, this worked for me on OS X v10.10.5 (Yosemite):

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
twm
  • 1,448
  • 11
  • 19
1

MacOS Ventura (13.0.1) - brew install git-gui worked for me.

ivan.ukr
  • 2,853
  • 1
  • 23
  • 41
0

First you need to check which version of Git you are running. The one installed with Homebrew 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 voilà! In case you are running on OS X v10.9 (Mavericks) you might need to install XQuartz.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

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"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sam
  • 5,997
  • 5
  • 46
  • 66