Why is VSCode not recognizing git?

Viewed 5064

I'm trying to upload my react app to my github, but VS code won't recognize Git command.

I have Git on PC. Path to git is correct, I checked multiple times. I have installed gh pages through vs code terminal. I have also added required changes to package.json. Now when I run git init in vs code terminal it throws an error that "git" is not a recognized command. Why is that happening and can someone help please.

This is the git path in vs code - "git.path": "C:/Program Files/Git/bin/git.exe" it is correct.

Git Enabled is checked as well.

package.json edits under the first {} "homepage": "http://greardrear.github.io/messenger", is added and under scripts added "predeploy": "npm run build", "deploy": "gh-pages -d build", .

And when I try to do " git init" or " git remote add origin" I get this message in vs terminal:

 git : The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program.  
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.    
At line:1 char:1
+ git
+ ~~~
    + CategoryInfo          : ObjectNotFound: (git:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException 

How can I fix this?

PS. I have tried all of the "fixes" to this issue I could find. I have also tried changing the path to "git.path": "C:/Program Files/Git/git-bash.exe" which also didn't work.

2 Answers

Firstly download and install the latest git from the link below:

https://git-scm.com/download/win

Then you have to add environment variables. Go to System Environment Variables and add the following:

C:\Program Files\Git\bin

C:\Program Files\Git\cmd

Click OK and close your terminal. Now open the terminal again and check the command your are looking for i.e. git --version(It gives you version have installed). Hope this works for you.

Related