英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论