-
Notifications
You must be signed in to change notification settings - Fork 8
Git for Windows
Your Name edited this page May 17, 2025
·
9 revisions
winget show --id Git.Git --versionswinget show --id Git.Gitwinget install --id Git.Git -e -h
# --accept-source-agreements
# --accept-package-agreements$git = Get-Command git -ErrorAction SilentlyContinue
if ($git) {
$gitVersion = git --version
Write-Host "Git is already installed: $gitVersion" -ForegroundColor Green
}
else {
Write-Host "Git is not installed." -ForegroundColor Yellow
}# Check if user.email is set
$currentEmail = git config --global user.email
if ([string]::IsNullOrWhiteSpace($currentEmail)) {
$userEmail = Read-Host "Enter your Git email address"
git config --global user.email "$userEmail"
Write-Host "Set git user.email to $userEmail" -ForegroundColor Green
} else {
Write-Host "Current git user.email: $currentEmail" -ForegroundColor Yellow
$changeEmail = Read-Host "Do you want to change it? (y/n)"
if ($changeEmail -eq 'y') {
$userEmail = Read-Host "Enter your new Git email address"
git config --global user.email "$userEmail"
Write-Host "Updated git user.email to $userEmail" -ForegroundColor Green
}
}
# Check if user.name is set
$currentName = git config --global user.name
if ([string]::IsNullOrWhiteSpace($currentName)) {
$userName = Read-Host "Enter your Git user name"
git config --global user.name "$userName"
Write-Host "Set git user.name to $userName" -ForegroundColor Green
} else {
Write-Host "Current git user.name: $currentName" -ForegroundColor Yellow
$changeName = Read-Host "Do you want to change it? (y/n)"
if ($changeName -eq 'y') {
$userName = Read-Host "Enter your new Git user name"
git config --global user.name "$userName"
Write-Host "Updated git user.name to $userName" -ForegroundColor Green
}
}
# Show final identity
$finalEmail = git config --global user.email
$finalName = git config --global user.name
Write-Host "\nYour global Git identity is now:" -ForegroundColor Cyan
Write-Host " Name : $finalName" -ForegroundColor White
Write-Host " Email: $finalEmail" -ForegroundColor White