Mac OS X Lion 上的 git

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6810059/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:24:51  来源:igfitidea点击:

git on Mac OS X Lion

gitmacososx-lion

提问by AnApprentice

I just upgraded my mac to LION, and now git is gone:

我刚刚将我的 mac 升级到 LION,现在 git 不见了:

$ git
-bash: git: command not found

Any ideas on how to get git back?

关于如何让git回来的任何想法?

回答by Chris Ledet

The default install location is /usr/local so add this to your ~/.bash_profile

默认安装位置是 /usr/local 所以把它添加到你的 ~/.bash_profile

export PATH=$PATH:/usr/local/git/bin/

export PATH=$PATH:/usr/local/git/bin/

then run source ~/.bash_profilein Terminal

然后source ~/.bash_profile在终端运行

回答by zakx

If you do not want to install XCode and/or ports/fink/homebrew, you could always use the standalone installer: http://code.google.com/p/git-osx-installer/

如果您不想安装 XCode 和/或 ports/fink/homebrew,您可以随时使用独立安装程序:http: //code.google.com/p/git-osx-installer/

回答by wezzy

you have to find where git is and then add the folder to the PATH variables in .bash_profile.

您必须找到 git 所在的位置,然后将该文件夹添加到 .bash_profile 中的 PATH 变量。

Using terminal:

使用终端:

1) search for git:

1)搜索git:

sudo find / -name git

2) edit the .bash_profile add

2) 编辑 .bash_profile 添加

PATH="<DIRECTORY OF GIT>:$PATH"

Git is back :-)

Git回来了:-)

Anyway i suggest you to install git using macports, in this way you can easilly upgrade your git to the newest release

无论如何,我建议您使用 macports 安装 git,这样您就可以轻松地将您的 git 升级到最新版本

Hope this helps

希望这可以帮助

回答by Abizern

There are a couple of points to this answer.

这个答案有几点。

Firstly, you don't need to install Xcode. The Git installer works perfectly well. However, if you want to use Git from within Xcode - it expects to find an installation under /usr/local/bin. If you have your own Git installed elsewhere - I've got a scriptthat fixes this.

首先,您不需要安装 Xcode。Git 安装程序运行良好。但是,如果您想在 Xcode 中使用 Git - 它需要在 /usr/local/bin 下找到安装。如果您在其他地方安装了自己的 Git - 我有一个脚本可以解决这个问题。

Second is to do with the path. My Git path used to be kept under /etc/paths.d/However, a Lion install overwrites the contents of this folder and the /etc/pathsfile as well. That's what happened to me and I got the same error. Recreating the path file fixed the problem.

二是与路径有关。我的 Git 路径曾经保存在/etc/paths.d/但是,Lion 安装也会覆盖此文件夹和/etc/paths文件的内容。这就是发生在我身上的事情,我遇到了同样的错误。重新创建路径文件解决了这个问题。

回答by jarjar

It's part of Xcode. You'll need to reinstall the developer tools.

它是 Xcode 的一部分。您需要重新安装开发人员工具。

回答by Manlio

You can always use port

您始终可以使用端口