72

When I ran git gui, I got this:

$ git gui
git: 'gui' is not a git command. See 'git --help'.

Did you mean one of these?
    grep
    init
    pull
    push

But I ran other git commands fine, including gitk. How can I fix this?

Thanks.

knocte
  • 16,941
  • 11
  • 79
  • 125
Victor
  • 13,010
  • 18
  • 83
  • 146
  • For [MacPorts](https://www.macports.org) users: This issue does *not* happen with the `git` installed by MacPorts (i.e., `git gui` works fine with that `git`, which is typically installed by MacPorts at `/opt/local/bin/git`), but this issue *does* happen with `/usr/bin/git`. So if you observe the reported error, then likely `/usr/bin/` appears in your environment's `PATH` *before* `/opt/local/bin` (assuming the latter is in the `PATH`). To find out, run `which -a git`. A convenient place to update the path is the file `~/.bashrc`. – 0 _ Jul 01 '21 at 10:18

9 Answers9

103

Edit your git config to an add an entry for gui in the alias section

nano ~/.gitconfig

[alias]

gui = !sh -c '/usr/local/git/libexec/git-core/git-gui'

Edit 2020

It looks like the path in the original answer is now obsolete. Updated instructions:

[alias]

gui = !sh -c '/usr/local/opt/git/bin/git gui'

Tyler A.
  • 3,048
  • 1
  • 23
  • 27
Drew
  • 4,683
  • 4
  • 35
  • 50
  • 24
    Or, to do this from the command line: `git config --global --add alias.gui '!sh -c '/usr/local/git/libexec/git-core/git-gui''` – nofinator Feb 05 '13 at 19:46
  • 4
    $ git gui sh: /usr/local/git/libexec/git-core/git-gui: No such file or directory fatal: While expanding alias 'gui': 'sh -c /usr/local/git/libexec/git-core/git-gui': No such file or directory – Elliot Oct 14 '13 at 05:15
  • 14
    As of OS X Mavericks and git-1.8.3.4, brew seems to install git to a slightly different path, that includes an `opt` : /usr/local/opt/git/libexec/git-core/git-gui – Roberto Tyley Nov 03 '13 at 20:00
  • @Roberto: I'm on Mavericks and git-1.8.3.4, and there is not `opt` in the path. – Lèse majesté Jan 29 '14 at 01:52
  • That didn't work very well for me - for example, "git gui blame" wouldn't bring up the blame gui. only the generic git-gui. – Rob Feb 04 '14 at 16:36
  • 1
    Been having the same error message on Linux Mint 18 on several different workstations. When starting `git-gui` from a menu in `gitk`, that error message prints to the console. This was the fix. Of course, the path to `git-gui` is different on Linux Mint but that path can be determined by running `locate git-core/git-gui`. Here's my config: `[alias] gui = !sh -c '/usr/lib/git-core/git-gui' ` – BarryPye Mar 11 '17 at 14:13
  • for those needing the path, try `which git-gui` - leaving this here as much as a reminder for myself as for others less familiar with terminal (: – Sandra Oct 13 '21 at 14:48
29

This post: http://www.cmsimike.com/blog/2012/07/30/git-gui-and-osx-mountain-lion/ saves me.

Edit ~/.bash_profile and put in

alias gui='/usr/local/git/libexec/git-core/git-gui'

Now the new command is gui instead of git gui.

EDIT (28 Jan 2013)

I have found a better answer to why git gui wasn't working: Did Apple remove the 'git gui' command in XCode 4.5 command line tools?. Please refer to this solution instead.

Apple did indeed remove the 'git gui' command. I decided to just homebrew git instead of relying on the XCode command line tools.

brew install git

Then I edited the /etc/paths file to have the /usr/local/bin directory come before the /usr/bin directory, because that wasn't right either. Then exited the terminal window and restarted, and now I get:

$ which git
/usr/local/bin/git

$ git --version
git version 1.7.12.1

and the git gui command works again.

EDIT (2020-02-03)

As of version 2.25.0_1, git gui is now provided by a separate formula in brew, named git-gui. See the following PR and issues for the background to this change: https://github.com/Homebrew/homebrew-core/pull/49136

So along with installing Homebrew's git, to have access to git gui one must run

brew install git-gui
Deniz Genç
  • 107
  • 1
  • 8
Victor
  • 13,010
  • 18
  • 83
  • 146
16

Seems like in mid-2021 all answers got obsolete (even mine!), so here's my new answer:

brew install git-gui || brew upgrade git-gui
git gui || /usr/local/opt/git/bin/git gui

OLD ANSWER: Seems like in late 2017 all answers above got obsolete, so here's my new answer:

brew install git || brew upgrade git
git gui || /usr/local/opt/git/bin/git gui
knocte
  • 16,941
  • 11
  • 79
  • 125
  • like the answers below, `git` and `git-gui` are now separate packages, but `git-gui` will also install `gitk`. I needed to also `ln -s /opt/homebrew/bin/git /usr/local/bin/` as my mac was refusing to pick up the new git version (2.33.1 at this time) – Sandra Oct 13 '21 at 14:46
13

2020

brew install git
brew install git-gui
git config --global --add alias.gui '!sh -c '/usr/local/opt/git/libexec/git-core/git-gui''

Now, enjoy:

git gui
FabianoLothor
  • 2,752
  • 4
  • 25
  • 39
  • 1
    Thanks for the 2020 update. I didn't need to add the global alias for it to work as expected. Brew installing both formulas alone did the trick. – Grafluxe Apr 02 '20 at 15:58
  • 4
    I needed to do only `brew install git-gui` and it started working. – kamlesh Sep 18 '20 at 07:48
  • make sure the path matches the location of `git-gui`. my gitk and git didn't need the alias configuring in git config, though I did symlink homebrew's git to my local bin – Sandra Oct 13 '21 at 14:53
3

You might need to install/upgrade separately the git-gui package after installing Mountain Lion.
As mentioned in "Git GUI client for Linux", git gui has its own package (beside git-core).

From the comments, it seems a git-gui package isn't yet available for Mountain Lion.
However, this post report making work an alternative gui like Source Tree.
That could be a good workaround.

Source Tree App

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I couldn't figure out how to install it as a separate package in Mac. – Victor Jul 30 '12 at 14:10
  • thanks. But I have done that, and ML doesn't allow it to install because it's not from a verified developer. – Victor Jul 30 '12 at 14:36
  • 1
    @Victor and following http://www.hongkiat.com/blog/mountain-lion-git-fix/ , would you see the git gui package? – VonC Jul 30 '12 at 14:51
  • That fixed the git command which I did earlier, after that git gui doesn't work still. – Victor Jul 30 '12 at 14:58
  • @Victor ok, so it was only about `git-core`, not `git-gui` package. – VonC Jul 30 '12 at 15:02
  • My git is working fine. Git status, gitk, etc. all work except git gui. – Victor Jul 30 '12 at 15:03
  • @Victor that leaves you with, pendng the publication of the git gui package, with alternative packages for gui like **SourceTree**: http://www.sourcetreeapp.com/ is supposed to work with ML (as mentioned 4 days ago in http://www.1771.in/coda-2-mountain-lion-git.html) – VonC Jul 30 '12 at 15:07
  • nice repo you used in your screenshot! – knocte Apr 26 '20 at 03:41
  • @knocte Why? It came from an article no longer available. (I now only find https://www.hongkiat.com/blog/mountain-lion-git-fix/) – VonC Apr 26 '20 at 18:18
  • cause it's mono :) – knocte Apr 26 '20 at 18:59
1

I have the same issue. Git-gui appears still installed for me (/usr/local/git/libexec/git-core/git-gui is my location) but it doesn't just work without specifying the full path. This indicates a path issue, but I've not looked into it much further.

edit Try adding /usr/local/git/libexec/git-core to the beginning of your PATH variable. Looks like all the git binaries are there so that should work.

Mike Megally
  • 153
  • 1
  • 9
1

Adding to the path worked for me.

I just added this line to my ~/.profile and git gui is alive once again. &(%ing mountain lion. export PATH=PATH:/usr/local/git/libexec/git-core

1

In addition to Victor's answer above, you need to an additional step, because brew install git didn't create simlink for git-gui.

Inside /usr/local/bin, run the following:

ln -s ../Cellar/git/1.8.3.2/libexec/git-core/git-gui git-gui

(Replace git version with your own)

hnchuong
  • 19
  • 3
0

While I am not sure how to open git gui from the terminal in Mountain Lion it is possible to use it using OpenInGitGUI which opens git gui from Finder. The download and instructions are available here.

This may not be quite as convenient as typing 'git gui' in the terminal but it is pretty close. Basically all you need to do is type 'open .' to open the current directory in Finder and then click the Git button to open up git gui.

Jeff Ames
  • 1,555
  • 11
  • 27