在 Mac 中安装后 git gui 不起作用(例如 Mountain Lion)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11722830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git gui not working after installing in Mac (e.g. Mountain Lion)
提问by Victor
When I ran git gui
, I got this:
当我跑时git gui
,我得到了这个:
$ 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?
但我运行其他 git 命令很好,包括gitk
. 我怎样才能解决这个问题?
Thanks.
谢谢。
回答by Drew
Edit your git config to an add an entry for gui in the alias section
编辑您的 git 配置以在别名部分中为 gui 添加一个条目
nano ~/.gitconfig
[alias]
gui = !sh -c '/usr/local/git/libexec/git-core/git-gui'
【别名】
gui = !sh -c '/usr/local/git/libexec/git-core/git-gui'
回答by Victor
This post: http://www.cmsimike.com/blog/2012/07/30/git-gui-and-osx-mountain-lion/saves me.
这篇文章:http: //www.cmsimike.com/blog/2012/07/30/git-gui-and-osx-mountain-lion/救了我。
Edit ~/.bash_profile
and put in
编辑~/.bash_profile
并放入
alias gui='/usr/local/git/libexec/git-core/git-gui'
Now the new command is gui
instead of git gui
.
现在新命令gui
代替了git gui
.
EDIT (28 Jan 2013)
编辑(2013 年 1 月 28 日)
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.
我找到了一个更好的答案来解释为什么git gui
不起作用:Apple 是否删除了 XCode 4.5 命令行工具中的“git gui”命令?. 请改为参考此解决方案。
Apple did indeed remove the 'git gui' command. I decided to just homebrew git instead of relying on the XCode command line tools.
Apple 确实删除了“git gui”命令。我决定只使用自制的 git 而不是依赖 XCode 命令行工具。
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:
然后我编辑了 /etc/paths 文件,将 /usr/local/bin 目录放在 /usr/bin 目录之前,因为这也不对。然后退出终端窗口并重新启动,现在我得到:
$ which git
/usr/local/bin/git
$ git --version
git version 1.7.12.1
and the git gui command works again.
并且 git gui 命令再次起作用。
EDIT (2020-02-03)
编辑 (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
从 2.25.0_1 版本开始,git gui
现在由 brew 中的一个单独公式提供,名为git-gui
. 有关此更改的背景,请参阅以下 PR 和问题:https: //github.com/Homebrew/homebrew-core/pull/49136
So along with installing Homebrew's git
, to have access to git gui
one must run
因此,除了安装 Homebrew 的git
,要访问git gui
必须运行
brew install git-gui
回答by knocte
Seems like in late 2017 all answers above got obsolete, so here's my new answer:
似乎在 2017 年末,上面的所有答案都已过时,所以这是我的新答案:
brew install git
/usr/local/opt/git/bin/git gui
回答by FabianoLothor
2020
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
回答by VonC
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
).
安装 Mountain Lion 后,您可能需要单独安装/升级 git-gui 包。
正如“ Linux 的 Git GUI 客户端”中提到的,git gui
有自己的包(在 旁边git-core
)。
From the comments, it seems a git-gui package isn't yet available for Mountain Lion.
However, this postreport making work an alternative guilike Source Tree.
That could be a good workaround.
从评论来看,似乎还没有适用于 Mountain Lion 的 git-gui 包。
但是,这篇文章报告使工作成为像Source Tree这样的替代 gui。
这可能是一个很好的解决方法。
回答by Mike Megally
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.
我有同样的问题。Git-gui 似乎仍然为我安装(/usr/local/git/libexec/git-core/git-gui 是我的位置),但它不能在没有指定完整路径的情况下工作。这表明路径问题,但我没有进一步研究它。
editTry 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.
编辑尝试将 /usr/local/git/libexec/git-core 添加到 PATH 变量的开头。看起来所有 git 二进制文件都在那里,所以应该可以工作。
回答by Bryan Lahartinger
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
我刚刚将此行添加到我的 ~/.profile 并且 git gui 再次活跃起来。&(%ing 山狮.export PATH=PATH:/usr/local/git/libexec/git-core
回答by hnchuong
In addition to Victor's answer above, you need to an additional step, because brew install git didn't create simlink for git-gui.
除了上面维克多的回答,你还需要一个额外的步骤,因为 brew install git 没有为 git-gui 创建 simlink。
Inside /usr/local/bin, run the following:
在 /usr/local/bin 中,运行以下命令:
ln -s ../Cellar/git/1.8.3.2/libexec/git-core/git-gui git-gui
ln -s ../Cellar/git/1.8.3.2/libexec/git-core/git-gui git-gui
(Replace git version with your own)
(用你自己的替换 git 版本)
回答by Jeff Ames
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.
虽然我不确定如何从 Mountain Lion 的终端打开 git gui,但可以使用 OpenInGitGUI 从 Finder 打开 git gui 来使用它。下载和说明可在此处获得。
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.
这可能不像在终端中输入“git gui”那么方便,但它非常接近。基本上你需要做的就是输入“open”。在 Finder 中打开当前目录,然后单击 Git 按钮打开 git gui。