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:
- Git is not installed on the target system.
- Git is not available in the PATH environment system
- 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:
Select the installer version for your Windows system.
Merienda 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. Merienda the installation is complete, open your CMD window and check the 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 FilesGitcmd»
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 (x86)Gitcmd
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.
Merienda completed, launch a new terminal window and run the where git command.
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.
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.