Powershell无法识别Git命令,即使有环境变量。

huangapple go评论104阅读模式
英文:

Powershell Doesn't Identify Git Commands Even With Environment Variable

问题

我的Power Shell完全不识别“git”命令,即使在删除环境变量并重新安装Windows 10后,甚至在重新安装Git之后也是如此。Git使用的环境变量路径是 C:\Program Files\Git\cmd。我不知道这是否有任何关联。Power Shell 表示它不将“git”识别为cmdlet、函数、脚本文件或可执行程序。

我已经尝试在互联网上查找是否有类似的问题,但提出的解决方案对我没有帮助。

英文:

My Power Shell does not recognize the "git" command at all even after I have reinstalled my Windows 10 after deleting my environment variable and not even after I have reinstalled Git. The environment variable path that Git uses is C:\Program Files\Git\cmd. I don't know if it has anything to do with it. Power Shell says it doesn't recognize "git" as a cmdlet, function, script file, or operable program.

I already tried to check if there was a similar problem on the internet, but the proposed solutions did not help me.

答案1

得分: 0

我在我的PowerShell中输入与你相同的内容时,会出现相同的错误,尽管我的git命令可以正常工作。你尝试过输入以下命令吗?这对我有效,因为它直接调用了cmd目录中的git应用程序。

& 'C:\Program Files\Git\cmd\git'

对于互联网上的其他人来说,ampersand & 表示让PowerShell知道字符串内部是你要运行的命令,这对于计算机命令而言很有用,因为目录名中可能包含空格。

英文:

I get the same error when I type in what you did on my Powershell, even though my git command works. Have you tried entering this command? This works for me since it directly calls the git application within the cmd directory.

& 'C:\Program Files\Git\cmd\git'

For others on the Internet, the ampersand & is to let Powershell know that the inside of the string is the command you want to run, which is helpful for computer commands where there may be a space in a directory name.

huangapple
  • 本文由 发表于 2023年6月1日 00:33:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76375626.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定