在Linux上更改git安装的位置 [英] Changing the location of git installation on linux
问题描述
如果这看起来很基础,我深表歉意,但是我是linux新手,因此不确定如何进行.我当前的git版本是1.7.1,位于/usr/bin/git中,但是/usr/src/git/bin/git中现在有较新版本的git(1.8).相对于1.7.1版本,我如何使git默认使用此版本?
I apologize if this seems basic but I'm new to linux and not really sure how to proceed. My current git version is 1.7.1 and is located in /usr/bin/git but a newer version of git (1.8) is now available in /usr/src/git/bin/git. How do I make git use this version by default as opposed to the 1.7.1 version?
推荐答案
您必须确保调用正确的可执行文件.这可以通过显式调用/usr/src/git/bin/git
而不是 git
来完成.当然,这总是很烦人,因此您可以通过添加以下行来使 git
成为该路径的别名
You have to make sure to call the right executable. This can ben done by explicitly calling /usr/src/git/bin/git
instead of git
. Of course this would be annoying to type all the time, so you can either make git
an alias for that path by adding the line
alias git=/usr/src/git/bin/git
添加到您的 .bashrc
中,或通过添加以下行将目录/usr/src/git/bin
添加到您的二进制搜索路径中
to your .bashrc
, or add the directory /usr/src/git/bin
to your binary search path by adding the line
export PATH="/usr/src/git/bin:$PATH"
要测试其他git安装是否在正确的位置搜索了核心二进制文件,可以检查 git --exec-path
的输出.
To test that the other git installation searches for the core binaries in the right place, you can check the output of git --exec-path
.
这篇关于在Linux上更改git安装的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!