How to resolve the error "git is not recognized" on windows
Encountering the error "git is not recognized" or "git command not found" typically indicates that Git is either not installed on your system or its installation path is not included in the system's PATH environment variable. This guide will help you troubleshoot and resolve these issues, ensuring that Git commands operate smoothly in your terminal or command prompt.
1. Verify git installation
The first step is to check whether Git is installed on your Windows machine.
Open the command prompt or PowerShell and run:
git --version
If Git is installed, you should see a version number as output.
- If you see an error like
"git is not recognized as an internal or external command
proceed to the next steps.
2. Install Git for Windows
If Git is not installed, you'll need to download and install it.
Download git: Visit the official Git website to download the latest version of Git for Windows.
Run the installer: Execute the downloaded file and follow the installation prompts. Default options are typically sufficient for most users.
Verify installation: Reopen the Command Prompt or PowerShell and type
git --version
to confirm Git is now recognized.
2a. Consider using the Graphite CLI
While Git is an incredibly useful tool, it has many shortcomings, particularly with rebasing, and managing stacked pull requests.
The Graphite CLI simplifies git
, handles rebasing automatically, and allows you to create, submit, and stack pull requests right from the command line.
Under the hood, the CLI runs Git to create branches, commits, and metadata, which means you can still use Git in your scripts, tooling, or whenever you feel like it. Read more about installing the Graphite CLI in our docs.
3. Add Git to the PATH Environment Variable
If Git is installed but not recognized, it's likely not added to the PATH environment variable. Adding Git to the PATH allows the system to locate the Git executable from any command line interface.
Find git installation path: The default installation path is usually
C:\Program Files\Git\cmd
. Verify this location exists or find where Git is installed on your machine.Edit system PATH:
Open the Start Menu Search, type in
env
, and choose "Edit the system environment variables".In the System Properties window, click on "Environment Variables".
Under "System variables", scroll to find the "Path" variable and select it, then click "Edit".
Click "New" and paste the path to your Git
cmd
folder (e.g.,C:\Program Files\Git\cmd
).Click "OK" to close all dialogs and apply these changes.
Verify the change: Close and reopen your Command Prompt or PowerShell and type
git --version
to ensure Git is now recognized.
4. Check for Typos in Commands
Sometimes, the issue might be as simple as a typo in the Git command you're trying to execute. Ensure you're typing the command correctly, such as git clone
instead of incorrectly spelled variations like gti clone
.
5. Use Git bash
If you continue to experience issues in the Command Prompt or PowerShell, consider using Git Bash, which is installed alongside Git for Windows. Git Bash provides a Unix-like terminal where Git commands should work without additional configuration.
Find and open Git Bash: Locate Git Bash in your Start Menu or use the search function to find it.
Try Your Git command: Use Git Bash to run the Git command that was previously not recognized.
6. Reinstall Git
As a last resort, if Git still isn't recognized, there might have been an issue with the initial installation.
Uninstall Git: Go to "Control Panel" > "Programs and Features", find Git in the list, and uninstall it.
Reinstall Git: Download the latest version of Git for Windows and follow the installation process again, making sure to add Git to the PATH during installation.
For further reading check out the official Git For Windows documentation.