简体   繁体   English

MacOSX Mountain Lion上的Xcode和Git安装

[英]Xcode and Git installation on MacOSX Mountain Lion

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 . 但是当我在shell终端中使用Git命令时,它会返回未找到命令的错误 Any suggestions? 有什么建议么? I have many Git repos on my mac, so I would like to reuse them without checking them out again :/ 我的mac上有很多Git repos,所以我想重新使用它们而不再检查它们:/

您需要安装命令行工具(请参阅Xcode - >首选项 - >下载),或者您可以从Apple Developer下载站点下载它。

First of all, installing the Xcode Command Line tools is probably not what you want. 首先,安装Xcode命令行工具可能不是你想要的。 See this post for more information: 有关更多信息,请参阅此帖子:

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. 您想要设置指向Xcode.app中存在的git(和svn等)版本的符号链接或别名。 This will cause you to automatically get newer versions when Xcode updates through the app store. 当Xcode通过应用商店更新时,这将使您自动获得更新的版本。 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. 安装命令行工具只会让事情变得混乱,因为最终会出现多个版本的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中的最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM