Why is git looking in the wrong directory for the git installation? (OS X)

心不动则不痛 提交于 2019-11-30 05:16:32

问题


I am new to OS X and cannot find anywhere how to fix this. I installed git but the installation was messed up and I had to remove it. I installed it using the latest git dmg file but whenever I type in

git

I get

-bash: /usr/bin/git: No such file or directory

That is because git is not installed in that directory and instead in /usr/local/bin/git

If I type in the entire path to the directory than I get the correct output.

So what did I do wrong and how do I fix it? Thanks.


回答1:


I know this is over a year old but just for anyone who experiences this issue:

I had a similar issue after renaming the OS X provided git client and installing using Homebrew. I found the issue was due to the current terminal session. The OP has the correct paths so I wouldn't recommend editing the /etc/paths file.

If after running which -a git you see /usr/local/bin/git everything should be correctly configured, open a new terminal and you should be able to run git with no errors.

Running which git should now output /usr/local/bin/git.




回答2:


It's not in your $PATH. It's installed in /usr/local/bin/git but your path only has

/usr/local/git/bin. Fixing the path should work.




回答3:


edit the file /etc/paths and add a line /usr/local/bin/

 echo "/usr/local/bin/" >> /etc/paths

you may have to run this command with sudo.

Open a new terminal window and type which -a git. If you see /usr/local/bin/git listed, you are all set.



来源:https://stackoverflow.com/questions/19698901/why-is-git-looking-in-the-wrong-directory-for-the-git-installation-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!