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

查看:28
本文介绍了使用自制软件版本覆盖 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 总是在 /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/Contents/Developer/usr/bin 中的 GIT.当您在 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. .bashrc.zshrc 中将路径更改为 PATH=/usr/local/bin:$PATH 如果您使用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天全站免登陆