I have an installation of Git for Windows, but when I try to use the git command in Command Prompt, I get the following error: ‘git’ is not recognized as an internal or external command, operable program or batch file. stackoverflow.com
As users reported, the error “git is not recognized as an internal or external command” happens when someone tries to run a git command in Windows Command Prompt. And here are two common reasons for this problem:
- Command Prompt has already been launched during the installation of Git.
- The Git path is not configured correctly.
In the following contents, some fixes for “git is not recognized” are listed. If you are facing the same error, you can try them one by one to solve the problem.
Fix 1: Restart Command Prompt
If you have already opened Command Prompt before you install the Git for Windows, the latest variables changes might not be updated, which could be one of the reasons why you got the error message “git is not recognized”. To solve the problem, you can:
Step 1: Exit Command Prompt.
Step 2: Press Win + S to open the Windows Search utility.
Step 3: Search for Command Prompt and right-click it. Then select Run as administrator.
Then you can try running a git command again and check if the error disappears. If this doesn’t work, you should move on to the next solution.
Fix 2: Reinstall Git for Windows
If the Git path is not configured correctly, you could also receive the error “git is not recognized as an internal or external command, operable program or batch file”. You can try reinstalling Git for Windows to set the path automatically.
Step 1: Open the Search utility and search for Control Panel. Then open it.
Step 2: Select View by: Category from the upper right corner. Then select Uninstall a program.
Step 3: In the list of installed programs and features, right-click your Git for Windows and select Uninstall. Then follow the onscreen instructions to finish the operation.
Step 4: Visit the official website of Git for Windows and download the latest program.
Step 5: Run the downloaded file and follow the wizard to install Git for Windows. When you get the “Adjusting your PATH environment” window, select Git from the command line and also from 3rd-party software and click Next.
Step 6: When the process is finished, restart your computer.
After reinstalling Git for Windows, you can open Command Prompt and check if it works properly.
Fix 3: Configure the Git Path Manually
This is an alternative method to fix 2. In this way, you don’t need to uninstall your Git for Windows and reinstall it. Here are the detailed steps.
Step 1: Press Win + E to open File Explorer and navigate to the installation folder of your Git for Windows and open the cmd folder. By default, it’s in one of the following locations:
- C:Program Filesgitcmd
- C:Program Files (x86)gitcmd
Step 2: Right-click git.exe and select Properties. In the pop-up window, copy the location.
Step 3: Press Win + R to invoke the Run window. Then type sysdm.cpl in the box and click OK to open System Properties.
Step 4: Click the Advanced tab and select Environment Variables.
Step 5: Under the System variables section, select Path and click Edit.
Step 6: In the following window, click the New button and paste the location you copied in the second step. Then press Enter to create the path.
Step 7: Click OK on each window to save the settings.
Now, the error “git is not recognized as an internal or external command, operable program or batch file” should have been solved.