0

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.

mklement0
  • 382,024
  • 64
  • 607
  • 775
  • Without additional information, your problem cannot be diagnosed. [This answer](https://stackoverflow.com/a/68414006/45375) contains detailed troubleshooting steps. If they help you solve your problem, we can close your question as a duplicate. If you've tried everything there and it still doesn't work, please provide more information. – mklement0 May 31 '23 at 18:28
  • Hello friend. I already managed to solve the problem, but without knowing how. What I can tell you is that it has to do with the Path system environment variable. I checked and saw that there are the following paths: %SystemRoot%\system32 - %SystemRoot% - %SystemRoot%\System32\Wbem - %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ - C:\Program Files\Git\cmd - C:\src\flutter\bin. Thank you for your willingness to respond. But what additional information would you need to answer this question? The ones I put weren't enough in what way? Thanks in advance – Sérgio Lima Jun 02 '23 at 12:04

1 Answers1

0

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.

ndhulipala
  • 112
  • 6
  • 1
    Sure, invocation by full path is an option - but inconvenient; adding a program's directory to `$env:PATH` is meant to avoid this inconvenience, and is definitely a solvable problem. If all else fails or you don't want to modify `$env:PATH`, you can get the same convenience with an _alias_, which - if put in the `$PROFILE` file - allows you to refer to Git just by `git` as well: `New-Alias git 'C:\Program Files\Git\cmd\git.exe'` – mklement0 May 31 '23 at 21:13
  • Hello friend. I already managed to solve the problem, but without knowing how. What I can tell you is that it has to do with the Path system environment variable. I checked and saw that there are the following paths: %SystemRoot%\system32 - %SystemRoot% - %SystemRoot%\System32\Wbem - %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ - C:\Program Files\Git\cmd. I realize that operations on the Path system environment variable can carry a lot of risk. Thank you for your willingness to respond. – Sérgio Lima Jun 02 '23 at 12:14