#!/bin/bash # Demo: Git Credential Manager in Console Mode # This script demonstrates how credential managers work without GUI echo "=== Git Credential Manager Console Demo ===" echo # Check available credential managers echo "1. Checking available credential managers..." if command -v git-credential-manager >/dev/null 2>&1; then echo "✓ Git Credential Manager (GCM) found: $(git-credential-manager --version)" else echo "✗ Git Credential Manager not found" fi if [[ "$OSTYPE" == "darwin"* ]]; then if git config --global --get credential.helper 2>/dev/null | grep -q "osxkeychain"; then echo "✓ macOS Keychain helper configured" fi elif [[ "$OSTYPE" == "linux-gnu"* ]]; then if command -v gnome-keyring-daemon >/dev/null 2>&1; then echo "✓ GNOME Keyring available" fi fi echo echo "2. Current Git credential configuration:" git config --global --show-origin --get credential.helper 2>/dev/null || echo "No global credential helper configured" echo echo "3. Testing credential storage (console mode)..." echo "This demonstrates how credentials are stored/retrieved without GUI" # Create a test credential input cat << 'EOF' | git credential-manager get 2>/dev/null || echo "Credential manager ready for input" protocol=https host=example.com username=testuser EOF echo echo "4. How it works in console:" echo " - First 'git push/pull' prompts for username/token" echo " - Credential manager stores them securely" echo " - Subsequent operations use stored credentials automatically" echo " - No GUI required - all terminal-based" echo echo "5. Available commands (all console-based):" echo " git credential-manager configure # Configure settings" echo " git credential-manager erase # Remove stored credentials" echo " git credential-manager approve # Approve credential storage" echo " git credential-manager reject # Reject credential storage" echo echo "=== Demo Complete ==="