tobias.henn
tobias.henn

Reputation: 225

How can i make ZSH use the latest git version?

I am using ZSH with oh-my-zsh on OS X.

Today I used hombrew to update to the latest version of git (1.8.something).

However, if I run

➜  ~  git --version
git version 1.7.10.2 (Apple Git-33)

I see that still an older version is used. On bash everything works fine and the latest version of git is called.

Since I am new to ZSH, any advice on how to set up ZSH to use the "new" git is appreciated!

Best,

Tobi

Upvotes: 2

Views: 2436

Answers (3)

Kalle Pokki
Kalle Pokki

Reputation: 5059

If the PATH modification didn't instantly work, you need to realize that with zsh you need to type "rehash" for zsh to recognize there are new executables in the path. Or just log out and back in.

Upvotes: 3

Danica
Danica

Reputation: 28846

This means that your $PATH variable isn't set up to include the right git (and everything else homebrew installs).

Try doing echo $PATH from both bash and zsh. You should see at least one difference: the directory where you installed homebrew, probably /usr/local/bin. (It'll either not be in there, or be after /usr/bin, where the Apple-supplied binary lives.)

To fix it, add a line like

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

to your ~/.zshenv.

Upvotes: 6

Anton Kovalenko
Anton Kovalenko

Reputation: 21507

Compare the outputs of which git (and the outputs of echo "$PATH") in bash and zsh.

The directory containing an up-to-date git is probably not present in $PATH variable for zsh, but it is in bash. It's likely caused by $PATH items being added in your ~/.bashrc and/or ~/.bash_profile file, which zsh doesn't source on startup. If it's so, add the same assignment to PATH to your ~/.zshrc

Upvotes: 1

Related Questions