Install Git for Windows or repair its PATH entry, then open a new PowerShell session and verify that git.exe is discoverable.
1. Determine whether Git is installed
Run:
$git = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $git) {
& $git --version
} else {
Write-Host 'Git for Windows is not installed in the standard location.'
}
- If a Git version appears, continue to Step 2.
- If the file is missing, install Git for Windows. Git is not included with Windows by default; after installation it should be usable from PowerShell.^1^
You can install it from PowerShell with:
winget install --id Git.Git -e --source winget
This WinGet command is documented by Microsoft.^2^
Alternatively, download the official Git for Windows installer and accept its default settings.^3^
After installation, close every PowerShell window and open a new one, then run:
git --version
2. Repair PATH if Git is installed
If the full-path command worked but git --version still does not, add Git’s command directory to the machine-level PATH.
Open PowerShell as Administrator, then run:
$gitPath = 'C:\Program Files\Git\cmd'
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
if (($machinePath -split ';') -notcontains $gitPath) {
[Environment]::SetEnvironmentVariable(
'Path',
"$machinePath;$gitPath",
'Machine'
)
}
Close PowerShell, open a new session, and verify:
Get-Command git
git --version
Get-Command discovers applications available through the current session’s PATH.^4^
Once git --version succeeds, configure the identity attached to your commits:
git config --global user.name "Your Name"
git config --global user.email "[Email]"
Then clone an existing GitHub repository:
cd C:\Projects
git clone https://github.com/OWNER/REPOSITORY.git
Git for Windows includes Git Credential Manager, so the first authenticated GitHub operation can prompt you to sign in. GitHub requires Git to be installed locally before it can be used from the command line.^5^
References
- Install and set up Git - Azure DevOps | Microsoft Learn
- Get started with Git from the command line
- Git - Install for Windows
- Get-Command-Syntax
- Set up Git - GitHub Docs