This tutorial on how to "properly install git" on OSX 10.8.5, says:

To run the latest version you need to adjust your shell path so that /usr/bin/git runs after /usr/local/bin


So add into the path [in my case: ~/.bash_profile] similar to the below and keep what you already have in the path, each segment is separated by a colon:

export PATH="/usr/local/bin:/usr/bin/git:/usr/bin:/usr/local/sbin:$PATH"

                                   ^ Focus on this

So my understanding is this:

  • when I log in, BASH will give priority to whatever is appended further on the right-hand side of the export PATH=... line
  • $PATH is at the righter-most : delimited entry in the export PATH=... line
  • $PATH contains /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

So... If my assumptions are correct, then surely the tutorial (quoted above) should have looked like:

export PATH="$PATH:/usr/bin/git"

Instead of:

export PATH="/usr/local/bin:/usr/bin/git:/usr/bin:/usr/local/sbin:$PATH"

My questions are:

Is the tutorial wrong? If not, then what of my assumptions are wrong? If my assumptions are not wrong AND the tutorial is not wrong, please explain why...

Note: I am aware this may not really be relevant to OSX 10.8.5, in which case please flag as off-topic to the appropriate Stack Exchange. But AFAIK, my Ubuntu machine has worked fine with ~/.bashrc having stuff like:

export PATH=$PATH:<myProgram1>:<myProgram2>:...

So it may be that BASH behaves differently in OSX? I don't know...

  • 1
    If /usr/bin/git is supposed to be after /usr/local/bin, then use export PATH="$PATH:/usr/bin/git", it's just that simple! Feb 27, 2017 at 23:44
  • @user3439894, cheers for now... but I think I would like some more specific details on how BASH works with OSX... if for example, the tutorial's version "worked" it would mean my whole understanding of BASH (at least in OSX) was wrong Feb 27, 2017 at 23:46
  • 1
    If you want to know how bash works, read its man page. How bash is depends more on its version then the OS. OS X/macOS tends to have older versions of bash then current Linux Distros. Feb 27, 2017 at 23:50

1 Answer 1


The tutorial is badly worded, one should never include a binary (like /usr/bin/git) into PATH, only directories. A better alternative would be to write

To run the latest version you need to adjust your shell path so that /usr/local/bin is searched before /usr/bin

So if you set PATH to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin the manually installed version of git will be picked from /usr/local/bin.

PS: Handling of PATH works the same for all Unix-based systems, the various directories are searched for the command from left to right.

  • 1
    You can also use the command which to determine, which command will be used. Just open your terminal and say which git and it will answer /usr/bin/git (in my case, yours might vary).
    – Jan
    Feb 28, 2017 at 12:49
  • 1
    Beware: the command which is based on your PATH within some shells. Rather use the builtin type which is made to analyse it but without depending on your PATH.
    – dan
    Feb 28, 2017 at 15:44
  • perhaps this is a paradigm shift for me... my understanding was the reverse. This essentially means @user3439894 was wrong in his comment on the OP? "If /usr/bin/git is supposed to be after /usr/local/bin, then use export PATH="$PATH:/usr/bin/git", it's just that simple!" Mar 1, 2017 at 16:32
  • 2
    @hello_there_andy user3439894 probably was led astray by the wording in the tutorial. "adjust your shell path so that /usr/bin/git runs after /usr/local/bin" just doesn't make sense.
    – nohillside
    Mar 1, 2017 at 16:36
  • 2
    Yes they do. I adopted this religion against which since a time where a typing error in .cshrc made this function to enter a recursive loop.
    – dan
    Mar 1, 2017 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .