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.

2
  • Without additional information, your problem cannot be diagnosed. This answer 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. Commented May 31, 2023 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 Commented Jun 2, 2023 at 12:04

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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'
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.