# Git Credentials Test Script # Tests your Git credential setup and provides troubleshooting Write-Host "" Write-Host "๐Ÿงช Git Credentials Test" -ForegroundColor Cyan Write-Host "======================" -ForegroundColor Cyan Write-Host "" # Check Git installation try { $gitVersion = git --version Write-Host "โœ… Git: $gitVersion" -ForegroundColor Green } catch { Write-Host "โŒ Git not found. Please install Git for Windows." -ForegroundColor Red Write-Host "Download: https://gitforwindows.org/" -ForegroundColor Yellow exit 1 } # Check if we're in a Git repository if (-not (Test-Path ".git")) { Write-Host "โŒ Not in a Git repository. Please run from the repository root." -ForegroundColor Red exit 1 } # Get repository info Write-Host "๐Ÿ“ Repository Information:" -ForegroundColor Magenta $remoteUrl = git remote get-url origin Write-Host "Remote URL: $remoteUrl" -ForegroundColor White $branch = git branch --show-current Write-Host "Current Branch: $branch" -ForegroundColor White Write-Host "" # Check Git configuration Write-Host "โš™๏ธ Git Configuration:" -ForegroundColor Magenta $userName = git config --global user.name $userEmail = git config --global user.email $credentialHelper = git config --global credential.helper Write-Host "User Name: $userName" -ForegroundColor White Write-Host "User Email: $userEmail" -ForegroundColor White Write-Host "Credential Helper: $credentialHelper" -ForegroundColor White Write-Host "" # Test credential helper Write-Host "๐Ÿ” Testing Credential Setup:" -ForegroundColor Magenta switch ($credentialHelper) { "manager" { Write-Host "โœ… Using Git Credential Manager (GCM)" -ForegroundColor Green Write-Host " GCM will open a browser for authentication" -ForegroundColor Gray } "gh" { Write-Host "โœ… Using GitHub CLI" -ForegroundColor Green Write-Host " Make sure you're logged in: gh auth status" -ForegroundColor Gray } "vscode" { Write-Host "โœ… Using VS Code credential helper" -ForegroundColor Green Write-Host " VS Code will prompt for credentials when needed" -ForegroundColor Gray } "store" { Write-Host "โš ๏ธ Using credential store (plain text)" -ForegroundColor Yellow Write-Host " Credentials stored in plain text file" -ForegroundColor Gray } "" { Write-Host "โŒ No credential helper configured" -ForegroundColor Red Write-Host " Run setup-git-credentials.ps1 to configure" -ForegroundColor Yellow } default { Write-Host "โ„น๏ธ Using custom credential helper: $credentialHelper" -ForegroundColor Blue } } # Check SSH keys if using SSH if ($remoteUrl -match "^git@") { Write-Host "" Write-Host "๐Ÿ” SSH Key Check:" -ForegroundColor Magenta $sshKeyPath = "$env:USERPROFILE\.ssh\id_ed25519" if (Test-Path $sshKeyPath) { Write-Host "โœ… SSH key found at: $sshKeyPath" -ForegroundColor Green # Test SSH connection Write-Host "Testing SSH connection..." -ForegroundColor Gray try { $sshTest = ssh -T git@git.d-popov.com "echo 'SSH connection successful'" 2>$null if ($LASTEXITCODE -eq 0) { Write-Host "โœ… SSH connection to git.d-popov.com works" -ForegroundColor Green } else { Write-Host "โŒ SSH connection failed. Check your SSH key setup." -ForegroundColor Red } } catch { Write-Host "โŒ SSH test failed. Make sure SSH is installed." -ForegroundColor Red } } else { Write-Host "โŒ SSH key not found at: $sshKeyPath" -ForegroundColor Red Write-Host " Run setup-git-credentials.ps1 and choose SSH option" -ForegroundColor Yellow } } # Test Git operations Write-Host "" Write-Host "๐Ÿงช Testing Git Operations:" -ForegroundColor Magenta Write-Host "Testing git fetch..." -ForegroundColor Gray try { git fetch --quiet Write-Host "โœ… git fetch successful" -ForegroundColor Green } catch { Write-Host "โŒ git fetch failed: $($_.Exception.Message)" -ForegroundColor Red } Write-Host "Testing git status..." -ForegroundColor Gray try { $status = git status --porcelain Write-Host "โœ… git status successful" -ForegroundColor Green if ($status) { Write-Host " Repository has uncommitted changes" -ForegroundColor Yellow } else { Write-Host " Working directory clean" -ForegroundColor Green } } catch { Write-Host "โŒ git status failed: $($_.Exception.Message)" -ForegroundColor Red } # Summary and recommendations Write-Host "" Write-Host "๐Ÿ“‹ Summary & Recommendations:" -ForegroundColor Magenta if (-not $credentialHelper) { Write-Host "โŒ No credential helper configured" -ForegroundColor Red Write-Host " โ†’ Run .\setup-git-credentials.ps1" -ForegroundColor Yellow } elseif ($credentialHelper -eq "store") { Write-Host "โš ๏ธ Using plain text credential storage" -ForegroundColor Yellow Write-Host " โ†’ Consider switching to SSH keys or GCM" -ForegroundColor Yellow } elseif ($remoteUrl -match "^git@" -and -not (Test-Path "$env:USERPROFILE\.ssh\id_ed25519")) { Write-Host "โš ๏ธ Using SSH but no SSH key found" -ForegroundColor Yellow Write-Host " โ†’ Set up SSH keys for passwordless authentication" -ForegroundColor Yellow } else { Write-Host "โœ… Credential setup looks good!" -ForegroundColor Green Write-Host " โ†’ You should be able to push/pull without prompts" -ForegroundColor Green } Write-Host "" Write-Host "๐Ÿ”ง Troubleshooting Commands:" -ForegroundColor Cyan Write-Host "โ€ข Clear stored credentials: git config --global --unset credential.helper" -ForegroundColor White Write-Host "โ€ข Reset credential helper: .\setup-git-credentials.ps1" -ForegroundColor White Write-Host "โ€ข Test SSH: ssh -T git@git.d-popov.com" -ForegroundColor White Write-Host "โ€ข Check Git config: git config --list --show-origin" -ForegroundColor White Write-Host "" Read-Host "Press Enter to continue"