AFTER THE GIT SOURCE CODE IS INSTALLED, AN ERROR IS REPORTED /USR/BIN/GIT: NO SUCH FILE OR DIRECTORY

phenomenon

After installing a git from the source code today, the following error was reported after executing the git command:

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

Analysis process

At first I thought it was a problem with the PATH path. Checking the PATH path found that it was normal, and it shouldn’t be the case when the command could not be found.

$ echo $PATH
 /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/admin/ bin
$ abcd
- bash: ABCD: the Command not found
$ /usr/local/bin/git - version
git version 2.17 . 0

It can be seen that the git command is under the PATH path and should be installed normally, because the absolute path can be used normally

And the error that the command cannot be found should be command not found

As the root user, it is normal to execute git –version. At first, I thought it was the admin user who set some variables, which led to the fixed search under /usr/bin when executing the git command.

Later, I found out that there is no such parameter

Finally found the answer on stackoverflow, the link is as follows:

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

It turns out that the old git path I uninstalled in advance is /usr/bin/git, and then the newly installed git is under /usr/local/bin, and the terminal session saves the original path. Reopen the new terminal to solve the problem.


Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *