benz
benz

Reputation: 4629

Updating Git to official distribution on MacBook Pro Sierra

I recently bought a MacBook Pro. I noticed that it comes with git pre-installed. This was not patched version of git. So after following certain tutorials, I used the following steps to update the git to the latest official distribution

  1. I installed Brew
  2. I ran the following command from brew

    brew install git
    
  3. Though when I ran the command git --version from the terminal, I was still pointing towards the previous version.

  4. I updated my path variable to point to my new official distribution git.

    export PATH=/usr/local/bin:$PATH
    

After this, I have seen my version is updated to the correct version. I have the following queries:

  1. Did I lose my offical mac version of git? If not, where is the mac version of git installed?
  2. I did not set the git environment variable in my bash profile, still when I close the terminal and re-open it, git version is correctly shown.
    1. How can i update my bash_profile to start reading from my newly installed git version?

Upvotes: 2

Views: 197

Answers (1)

Schwern
Schwern

Reputation: 164919

Did I lose my offical mac version of git?

No.

If not, where is the mac version of git installed?

/usr/bin/git. You can find all instances of git in your PATH with which -a git.

I did not set the git environment variable in my bash profile, still when I close the terminal and re-open it, git version is correctly shown. How can i update my bash_profile to start reading from my newly installed git version?

You've only set the PATH for that current instance of the shell. You need to set it in your shell config.

You can edit ~/.bash_profile and add the same line you used in your shell: export PATH=/usr/local/bin:$PATH. But you shouldn't have to, /usr/local/bin should already be in your PATH, that's why brew uses it. It's possible you installed another version of git in front of /usr/local/bin (which -a git will tell you).

Try running brew doctor. See the brew troubleshooting guide for details.

Upvotes: 4

Related Questions