How To Fix Git Is Not Recognized As An Internal Or External Command Operable Program Or Batch File Error
You will get this error for two main reasons. One, is Git is not installed on your system at all. Head over to official git page, download it and run the installation file. And second, Git is installed, but it's installation path wasn't added to Environment Variables on your Windows system.
This error means just what it says. In attempt to find a command, executable program, or batch file, Windows failed to do it, after searching anywhere in the system.
Or just watch this quick YouTube video explaining how to fix git not recognized error:
How to fix: git not recognized as a command, program or batch file error
Note, this doesn't mean Git isn't installed. Just that it isn't added to environment variables.
In case of git, however, this means Windows cannot find git.exe command.
Type git --version on the command line:
C:\>git --version
git version 2.39.1.windows.1
But what if you get an error every time you run git command? Like this one:
C:\>git --version
'git' is not recognized as an internal or external command,
operable program or batch file.
This is not a git error. It's a Windows error.
You can type asdasd into command prompt, and you'll get the same error for asdasd.
If the folder your Git was installed in was not added to Environment Variables, you will not be able to run git command from anywhere on your hard drive, except that folder.
This tutorial was created to help you fix the git is not recognized as internal or external command error. It may also say operable program or batch file. It might sound confusing, at first. However, this is a fairly common error with a very easy solution.
How To Fix Git Is Not Recognized As Internal Or External Command
First, identify where Git is installed on your system.
This is the folder specified when you were installing it from the official Git installer file.
By default it can be somewhere in your Program Files directory. For this example, to keep things simple, we will assume you installed Git into C:\Git directory.
To fix git is not recognized as internal or external command, operable program or batch file, follow these steps:
- Click Start button.
- Start typing "environment variables", and press Enter.
- Click on Environment Variables button, close to lower right corner.
- Click anywhere in lower box that says System Variables.
- Scroll down until you see Path variable, and click on it once.
- Click on Edit button to start editing Path variable.
- Click New button to start a new blank variable.
- Type path to where your Git is installed on your system.
- Click Okay button 3 times in a row to exist and save your path variable.
Now for visual speed-learners, let's go over each step in detail:
Click Start button.
This one's easy. Just click on Start button from your Windows desktop.
Start typing "environment variables", and press Enter.
First, click on Start button and start typing "environment variables."
You don't even have to finish typing the complete phrase.
Just press Enter or Open button.
Click on Environment Variables button, close to lower right corner.
On this System Properties window that opens, click Environment Variables... button:
This leads us to the next step.
Click anywhere in lower box that says System Variables.
There are two main types of Environment Variables.
They are displayed on two separate lists on this window:
Both lists have the path variable on them. So how do we know which one to choose?
The upper box is user variables. Add your git path in this box, if you want git to be available on the command line from any hard drive location, even C:\, and not just the folder where git was installed. The idea behind user variables is that only the currently logged in Windows user's system configuration will be affected.
The lower box is called system variables. Adding git to path here, will end up applying it systemwide. Regardless who is logged in, Windows will recognize git command anywhere on the command line.
I personally use system variables, because nobody else is using my computer anyway.
Scroll down until you see Path variable, and click on it once.
Choose your list, and scroll down to find Path variable.
Click on the Path variable just one time to select it.
Click on Edit button to start editing Path variable.
Then click Edit button just underneath the list.
Now this new window should open that looks like this:
The Path variable contains multiple entries for all kinds of other programs.
This is the list to which we need to add the path to the folder where our git is installed.
In other words, the directory where the executable file git.exe is located.
Click New button to start a new blank variable.
Now, click on New button to add a new Environment Variable:
Type the location of your Git installation into this new input box at the bottom.
Type path to where your Git is installed on your system.
Simply start typing the path.
For example: C:\Git or C:\Program Files\Git.
Whatever the folder is where GIt was installed.
Click Okay button 3 times in a row to exist and save your path variable.
Press Enter to confirm your path.
Now to exit out of all Environment Variables windows, click Okay button 3 times, until all windows disappear.
Congratulations! At this point your git has been added to system Path using environment variables.
Go to your cmd.exe and navigate to C:\ drive to verify if you can call git command:
C:\>git --version
git version 2.39.1.windows.1
As you can see you can now call git on the command line from any hard drive location. This means other programs like VSCode, or Visual Studio, can call this command too from their own environments.
It took hours to put this material together. Please help me out by sharing it ๐
Click button below to share link on WhatsApp or Discord or with friends:
Hope this helps someone ๐ Please share this page!