15

I'm trying to clone a project of GitHub into Visual Studio, so I go to New Terminal and type:

git clone [CLONE WITH SSH LINK]

and it shows:

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.

However, I have already installed Git and Git is set to Enabled at Visual Studio settings.

Why does this error occur, and how can I fix it?

And how can I set/change the path of Git in Visual Studio...

8

6 Answers 6

9

Reinstall Git and reopen the editor

I solved the same problem by reinstalling Git.

And refreshed npm.

Then I closed the editor and reopened it.

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

1 Comment

9

The reason behind it is that you might have not added the Path environment variable. So here are the steps for that.

Go to Environment Variable. Click on to the Path variable, Edit and add it to the path given below:

C:\Program Files\Git\bin

C:\Program Files\Git\cmd

Click OK and close your terminal. Now open the terminal and check the command. You're looking for e.g. git --version. It gives you the version you have installed.

3 Comments

On Windows, presumably? The question is probably about Visual Studio Code, not Visual Studio. Though it could still be on Windows.
It is odd that the installation hadn't added paths automatically, but adding manually worked. My prior git installations were adding paths automatically.
This was the issue for me. Don't know why it did not add path variables automatically. Thank you.
0

I just reopened Visual Studio right after installing Git and that solved the issue for me! Just make sure to make it default for Visual Studio and allow third party command prompt.

Comments

0

You will need to add the bin and cmd file paths for the GIT program file in the environment variable. Find the environment variable by searching in your computer to add the file paths. Afterwards just restart your terminal.

2 Comments

Didn't Mohammed already say this nearly two years ago? Please don't repeat answers.
Yes Mohammed did. Thanks a lot for the feedback. I just felt I could give my version hopefully simplify for a someone new in tech.
0

After Opening a new folder in Visual Studio Code select gitbash option that is present under powershell option in right corner and then use the terminal. ☺️☺️

Comments

-1

BRIEF: Run your editor, such as vim or vscode, with Administrator privileges (after installing git from git-scm.com).

Error "'git' is not recognized as the name of a cmdlet"

3 Comments

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
i improved the answer.
"Run your editor ... with Administrator privileges" - What the hell? No, don't do that. Don't use admin privileges unless they're necessary. Instead, fix your non-admin setup, cf Mohammed's answer.

Your Answer

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