| by Arround The Web | No comments

Git is Not Recognized as an Internal or External Command, Operable Program or Batch File

Git has been a revolutionary technology and tool for every modern software developer. Version control tools let you keep track of the changes and preserve a source code snapshot if you need to revert the changes.

Whether you are working on a small or a massive software project, using a git repository to manage it can be more than beneficial.

Before using git on your system, you need to install and configure it. Git is cross-platform and can be installed on any system running Windows, macOS, or Linux.

On Windows, you may face the “git is not recognized as an internal, external command, operable program, or batch file” error even after installing git.

What causes “‘git’ is not recognized as an internal or external command, operable program or batch file.” Error?

There are three major causes of the error. These includes:

  1. Git is not installed on the target system.
  2. Git is not available in the PATH environment system
  3. The terminal session is not reloaded after installing git.

Fix #1 Git is not installed on the target system.

Before using git, you must ensure you have it installed and configured on your system. Although there are several methods of installing git on Windows, it is recommended to use the official git for Windows installer.

Open your browser and navigate to the resource below:

https://git-scm.com/download/win

Select the installer version for your Windows system.

Once the download is complete, launch the installer wizard and follow along with the installation instructions.

You can accept the default values as they work well out of the box.

Under the “Adjusting your PATH environment.”, select “Git from the command line and 3rd-party software.”

The above option adds git to your PATH environment variable. This helps you access the git utility from any directory in your command prompt and any third-party software such as your code editor.

Continue with the setup wizard and complete the installation process. Once the installation is complete, open your CMD window and check the git version.

$ git --version

Fix #2 Git is not available in the PATH environment system

Suppose you have git installed and still getting the “‘git’ is not recognized as an internal or external command, operable program or batch file.” error. In that case, the error is caused by git missing from the PATH environment variable.

You can fix that by manually adding git in your system environment variable. You can run:

setx /M path "%path%;C:\Program Files\Git\cmd"

The command above should update your system’s environment variables to include the path to the git binary.

If you are looking for a graphical method, start by navigating to the git binary in file explorer.

By default, you will find it in either of these directories.

C:\Program Files\Git\cmd

C:\Program Files (x86)\Git\cmd

Select the full path in the Windows explorer path bar and click copy.

Press the Windows Key + R to launch the Run dialog.

Enter sysdm.cpl to launch the System properties window.

Under “Advanced,” select “Environment Variables.”

Go to “System Variables” and select “Path.” Then, click on Edit to edit the Path environment variable.

Click on New and paste the path you copied earlier.

Click on OK to save the changes.

Once completed, launch a new terminal window and run the where git command.

$ where git

Fix #3 Reload Terminal Session

You will need to reload the session to update the environment variables if you have a terminal session open when installing git.

You can do this by closing and opening a new terminal session.

Closing

Using this tutorial, you discovered three significant causes of the “git command not recognized…” error. You also learned three ways to fix this error if it arises in your system.

Share Button

Source: linuxhint.com

Leave a Reply