How to Fix: Git Is Not Recognized as an Internal or External Command Error

John Wachira Feb 15, 2024
How to Fix: Git Is Not Recognized as an Internal or External Command Error

This article discusses three methods we can employ to fix the error 'git' is not recognized as an internal or external command when using Git on the Command Prompt on Windows.

It is a commonly reported error by users who prefer running Git commands on the CMD instead of Git Bash. We got you if you are a Command Prompt fanatic struggling with this error.

Fix 'git' is not recognized as an internal or external command Error

git is not recognized error

Before fixing an error or any problem, you must first identify the cause.

So, what causes the 'git' is not recognized as an internal or external command error?

  1. The Git Path is not set or is incorrectly set in Variables.
  2. The Command Prompt was running during the installation of Git.

Here are three troubleshooting guides you can employ to fix this issue.

Re-Open Command Prompt

If you always have CMD running on your machine and install Git without closing the terminal, you will likely encounter this error. This issue occurs because your system has failed to update the Command Prompt with the latest Variable changes.

Closing and opening the Command Prompt should fix the issue. If the path is set correctly, you should be able to use Git on the CMD without encountering the error.

Automatically Add Git PATH to Variables

This section is for those who do not want to mess up their PATH variables.

You can use the Git GUI to automatically create and add the path for you. You will have to uninstall and install Git again.

Follow these steps to fix the 'git' is not recognized as an internal or external command error.

  1. Use the Windows+R to open the Run dialog box. To open Programs and Features, type "appwiz.cl" and hit Enter.

  2. In the Programs and Features tab, locate your Git entry, right-click on it and select Uninstall to remove Git from your machine.

  3. Once done, download the latest Git executable file or use the one you had previously used to install Git on your machine.

  4. Follow the prompts and leave everything to default. Once you get to the Adjusting your PATH environment tab, select the second option, as shown below.

    Adjusting your PATH environment

  5. Finish the installation process.

This should fix the error. You should be able to use Git commands on the Command Prompt.

Manually Add Git PATH to Variables

If the Git variable is not configured or incorrectly configured in the Environment Variables, you will have issues working with Git commands on the Command Prompt.

To manually configure the path, follow these steps.

  1. Navigate to the Git installation folder on your computer. Here are the common installation paths depending on your system’s architecture.

    For x86 versions: My Computer (This PC) > Local Disk(C:) > Program Files (x86) > Git > cmd

    For x64 versions: My Computer (This PC) > Local Disk(C:) > Program Files > Git > cmd

  2. Open the Properties tab for the Git executable file and copy the Location path.

    Location path

  3. Open the Run dialog box, type sysdm.cpl and hit Enter to the System Properties window. Select Environment Variables in the Advanced tab.

    System Properties

  4. On the System Variables submenu, click on Path and hit Edit.

    System variables

  5. Select New on the Edit Environment Variables tab and paste the location we had copied in step two.

    edit environment variables

  6. Click OK to save the changes and launch your Command Prompt.

    You should be able to use Git commands on the Command Prompt without issues.

    git on command prompt

In summary, if you are getting the 'git' is not recognized as an internal or external command error while using Git commands on the Command Prompt, you will need to set the Git PATH variable. As we discussed, there are two ways of doing this.

Author: John Wachira
John Wachira avatar John Wachira avatar

John is a Git and PowerShell geek. He uses his expertise in the version control system to help businesses manage their source code. According to him, Shell scripting is the number one choice for automating the management of systems.

LinkedIn

Related Article - Git Error