windows 将 Git 添加到 PATH 变量 - 在 AppData/Local 下找不到 GitHub

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31167181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:09:24  来源:igfitidea点击:

Adding Git to PATH Variable - Can't find GitHub under AppData/Local

windowsgitcommand-lineinstallationpath-variables

提问by Richard Hamilton

I was following this guide here on how to add Gitto my Path variable so I can use it from the command line (Not just Git Bash).

我在这里遵循本指南,了解如何添加Git到我的 Path 变量,以便我可以从命令行(不仅仅是 Git Bash)使用它。

Installing Git in PATH with GitHub client for Windows

使用适用于 Windows 的 GitHub 客户端在 PATH 中安装 Git

To quote an answer, Git was supposedly located here

引用一个答案,Git 应该位于这里

Get the Git URL

We need to get the url of the Git \cmd directory your computer. Git is located here:

C:\Users\\AppData\Local\GitHub\PortableGit_\bin\git.exe

获取 Git 网址

我们需要获取您计算机的 Git\cmd 目录的 url。Git位于:

C:\Users\\AppData\Local\GitHub\PortableGit_\bin\git.exe

I opened File Explorer and went to the directory C:\Users\AppData\Local\

我打开文件资源管理器并转到目录 C:\Users\AppData\Local\

Under the view tab, I have Hidden Itemschecked. I cannot see a GitHub folder listed. In the search bar, I appended GitHub to the end of the directory path and got the following message

在视图选项卡下,我已经Hidden Items检查过。我看不到列出的 GitHub 文件夹。在搜索栏中,我将 GitHub 附加到目录路径的末尾并得到以下消息

Windows can't find 'C:\Users\username\AppData\Local\GitHub'. Check the spelling and try again.

I'm trying to add Git to my environment path variable, but can't find where git is located.

我正在尝试将 Git 添加到我的环境路径变量中,但找不到 git 所在的位置。

In Git Bash, I was able to try which gitwhere I got /bin/git

在 Git Bash 中,我能够尝试which git我得到的地方/bin/git

But I'm not sure how I can find what to put in under environment variable.

但我不确定如何在环境变量下找到要放入的内容。

Doing a random search, I actually found that the Git folder was located here

随便搜了一下,居然发现Git文件夹就在这里

C:\ProgramFiles(x86)\Git

But what am I supposed to enter for the path variable? This is different from the answer in the other question.

但是我应该为路径变量输入什么?这与另一个问题的答案不同。

回答by Ben Paz

Just add the path to the command. This was the path to add to the end of the windows PATH.

只需将路径添加到命令中即可。这是添加到 Windows PATH 末尾的路径。

C:\Program Files\Git\bin\

Now we should be able to find git.exeby typing

现在我们应该可以git.exe通过输入找到

git

回答by Richard Hamilton

It turns out Git was being sneaky!

事实证明,Git 是偷偷摸摸的!

It was supposed to be installed in AppData/Local, but was actually installed in the Program Files(x86)directory.

它应该安装在 中AppData/Local,但实际上安装在Program Files(x86)目录中。

I added this to my Path variable after a semicolon

我在分号后将它添加到我的 Path 变量中

C:\Windows\Program Files(x86)\Git\bin\git.exe

And magically, I can run git again.

神奇的是,我可以再次运行 git。

回答by James Drinkard

For Windows 7 using GIT 2.7.2 I used this in the path under environment variables:

对于使用 GIT 2.7.2 的 Windows 7,我在环境变量下的路径中使用了它:

;C:\Program Files\Git\bin;C:\Program Files\Git\bin\cmd. I then typed git --version from a command prompt and got:

;C:\Program Files\Git\bin;C:\Program Files\Git\bin\cmd. 然后我从命令提示符输入 git --version 并得到:

git version 2.7.2.windows.1

回答by Zulder

Another way is found in this place https://stackoverflow.com/a/34767523/5842689

另一种方法是在这个地方https://stackoverflow.com/a/34767523/5842689

the best thing is you can test if work in cmd.

最好的事情是你可以测试是否在 cmd 中工作。

"o verify, restart cmd and type git --version in cmd"

“o 验证,重新启动 cmd 并在 cmd 中输入 git --version”

it works for me cause the real path in my case (Win10 x64)is C:\Program Files (x86)\Git\bin\git.exe

它对我有用,因为在我的情况下(Win10 x64)的真实路径是 C:\Program Files (x86)\Git\bin\git.exe