MacOSX Mountain Lion 上的 Xcode 和 Git 安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12842165/
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
Xcode and Git installation on MacOSX Mountain Lion
提问by itsme
I just installed Mountain Lion and Xcode, so under /Applications/Xcode.app/Contents/Developer/usr/bin
I found the Git directory
我刚刚安装了Mountain Lion和Xcode,所以在/Applications/Xcode.app/Contents/Developer/usr/bin
我下面找到了Git目录
But when I use Git commands in the shell terminal it returns error of command not found. Any suggestions? I have many Git repos on my mac, so I would like to reuse them without checking them out again :/
但是当我在 shell 终端中使用 Git 命令时,它会返回命令未找到的错误。有什么建议?我的 mac 上有很多 Git 存储库,所以我想重用它们而不用再次检查它们:/
回答by trojanfoe
You need to install the command line tools (see Xcode -> Preferences -> Downloads) or you can download it from the Apple Developer Download site.
您需要安装命令行工具(请参阅 Xcode -> Preferences -> Downloads),或者您可以从Apple Developer Download 站点下载。
回答by Mike Weller
First of all, installing the Xcode Command Line tools is probably not what you want. See this post for more information:
首先,安装 Xcode 命令行工具可能不是您想要的。有关更多信息,请参阅此帖子:
http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
You want to set up symbolic links or aliases that point to the versions of git (and svn etc.) that exist inside Xcode.app. This will cause you to automatically get newer versions when Xcode updates through the app store. Installing the command line tools will only confuse matters because you will end up with multiple versions of git lying around, and you will have to manually update the command line tools.
您想要设置指向 Xcode.app 中存在的 git(和 svn 等)版本的符号链接或别名。这将使您在 Xcode 通过应用商店更新时自动获取更新版本。安装命令行工具只会使事情变得混乱,因为您最终会遇到多个版本的 git,并且您将不得不手动更新命令行工具。
The commands you will need are:
您将需要的命令是:
sudo xcode-select --switch /Applications/Xcode.app # tells 'xcrun' where to look
And then in your shell profile, for example .bash_profile
:
然后在您的 shell 配置文件中,例如.bash_profile
:
alias git='xcrun git' # use 'xcrun' to locate the git binary
Now running 'git' from the terminal will use the latest version inside Xcode.app.
现在从终端运行 'git' 将使用 Xcode.app 中的最新版本。