使用自制软件版本覆盖Xcode的Git [英] override git from Xcode with homebrew version

查看:117
本文介绍了使用自制软件版本覆盖Xcode的Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了XCode,因此git也在那里。因为我想要一个新版本的git,我使用自制软件安装。

I've installed XCode and therefore git is there as well. Since i want to have a newer version of git I installed using homebrew.

但是自制版本的git从来没有被调用过,因为我的PATH看起来像这样

But the homebrew version of git is never called since my PATH looks like this

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

这意味着 / usr / bin / git 是allways之前调用 / usr / local / bin / git

which means the /usr/bin/git is allways called before /usr/local/bin/git.

是否有方法可以在不更改PATH?

Is there a way to change that without changing the PATH?

推荐答案

Xcode实际上使用存储在 /Applications/Xcode.app/中的GIT内容/开发者的/ usr / bin中。当您将命令行工具安装为Xcode安装的一部分时,相同版本的GIT将安装在 / usr / bin 中。所以,你将无法改变Xcode正在使用的内容(除非你愿意使用Xcode包的内容)。如果从终端应用程序中,您想要使用自制软件安装的GIT,那么您有两种选择:

Xcode is actually using the GIT that is stored in /Applications/Xcode.app/Contents/Developer/usr/bin. The same version of GIT gets installed in /usr/bin when you installed the command line tools as part of Xcode installation. So, you won't be able to change what Xcode is using (unless you are willing to muck with the contents of the Xcode package). If, from a terminal application, you want to use the homebrew-installed GIT then you have two options:


  1. 参考GIT与完整路径作为 / usr / local / bin / git ... 对于这种情况,您可以创建一个别名,如 alias mgit = / usr / local / bin / git 然后从终端使用 mgit ...
  2. 将路径更改为<$ c $在你的 .bashrc 或者 .zshrc 中使用PATH = / usr / local / bin:$ PATH c $ c>如果你使用zsh文件(或者每次你在命令行启动一个终端)。

  1. Reference GIT with the full path as /usr/local/bin/git ... For this case you can create an alias like alias mgit=/usr/local/bin/git and then use mgit ... from the terminal
  2. Change the path as PATH=/usr/local/bin:$PATH either in your .bashrc or .zshrc if you use zsh file (or each time you start a terminal at the command line).

这篇关于使用自制软件版本覆盖Xcode的Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆