简体   繁体   中英

Changing the location of git installation on linux

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?

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

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"

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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