Open In App

How To Resolve Error "Git is not recognized" on Windows?

Last Updated : 29 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The "Git is not recognized as an internal or external command" error is a common issue faced by Windows users when trying to run Git commands from the Command Prompt or PowerShell. This error occurs because Git is not added to the system’s PATH environment variable, which is necessary for the operating system to locate the Git executable. In this article, we'll explore several methods to resolve this error.

Common Causes:

  1. Git is not installed.
  2. The Git installation path is not added to the system’s PATH environment variable.
  3. Incorrect or incomplete installation of Git.

There are several ways to resolve the "git is not recognized" error:

Approach 1: Check if Git is Installed

First, verify whether Git is installed on your system:

Step 1: Open Command Prompt or PowerShell.

Step 2: Type git --version and press Enter.

Expected Output:

If Git is installed, you should see a version number like:

git version 2.40.0.windows.1
git-v
git --version


If you see the error "git is not recognized", Git is either not installed or not configured correctly.

Approach 2: Add Git to the System’s PATH Manually

If Git is installed but not recognized, you need to manually add its installation path to the PATH environment variable.

Step 1: Find the Git Installation Path:

By default, Git is installed in a directory like:

C:\Program Files\Git\bin

You can check this path by navigating to where Git was installed.

Step 2: Add the Path to the Environment Variable:

  1. Right-click on This PC or My Computer and select Properties.
  2. Click Advanced system settings on the left.
  3. In the System Properties window, click the Environment Variables button.
  4. In the Environment Variables window, find the Path variable under System variables and select Edit.
  5. Click New and add the Git installation path (e.g., C:\Program Files\Git\bin).
env-git
PATH

6. Click OK to save the changes.

env
Environment Variables


Verify the PATH:

Open Command Prompt again and type git --version. If everything is set correctly, you should see the Git version information instead of the error.

Approach 3: Reinstall Git and Select the PATH Option

If adding Git to the PATH manually doesn’t work, reinstall Git with the correct settings:

  • Download the latest version of Git from the official website.
  • Run the installer and follow the steps.
  • During the installation process, when you reach the step that says Adjusting your PATH environment, select the option Use Git from the command line and also from 3rd-party software.
  • Complete the installation.
  • Open Command Prompt and type git --version to verify the installation.

Approach 4: Verify the PATH is Correct

Sometimes the PATH variable may have an incorrect or incomplete Git path. To verify:

  • Follow the same steps as in approach 2 to open the Environment Variables window.
  • In the Path variable, check if the Git path is correct and points to the bin or cmd directory inside the Git installation folder.
  • If the path is incorrect, correct it by clicking Edit and providing the accurate path.

Next Article
Article Tags :

Similar Reads