Install git in window 10

I have installed git in my pc(windows 10) and set environment variable path also. But when I try to download WPCS using git git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs getting an error

'git' is not recognized as an internal or external command, operable program or batch file.

Git directory path is C:\Program Files\Git and I have set the environment variable as C:\Program Files\Git\cmd. Can anyone suggest me what might be the problem here? I have tried this commands also

enter image description here

3 answers

  • answered 2018-11-08 08:12 camilo.forero

    If you already installed the git-scm.com version, you can use my second favourite on top of it, Git for Windows (https://gitforwindows.org)

    It will support your Git installation out of the box without messing around with environment variables and it uses Git Bash, which emulates a common Linux command line, so most git commands you will find around on the web will work for you

    If you do this, you shouldn't try to run git directly from the Windows command line, but from the Git Bash command line, which will be accessible everywhere in Windows from the right click menu

  • answered 2018-11-08 08:15 Nghia Bui

    Please select the option Use Git from the Windows Command Prompt when installing git:

    enter image description here

    The option basically adds the path C:\Program Files\Git\cmd to the Path System Variable of Windows, make sure you have it there:

    enter image description here

    Also try to close the cmd window and open it gain, or even try to restart your PC.

  • answered 2018-11-08 09:41 Philippe

    It's surely a problem of environment variable refresh (accepting that you selected the good option to update the PATH in the installer).

    Environment variables (and, so the PATH) of a process (here cmd.exe) are inherited from the ones of the parent process at the creation of the process.

    When the env var is rightly set, restarting the computer is a solution that always works.

    You could also, as a workaround, open the task manager and kill and restart all the explorer.exe process to force the refresh of env variables.

    And then all the new processes created from him will have the good refreshed values. That should work (depending on how you open you command prompt ;) )