172 lines
4.2 KiB
Markdown
172 lines
4.2 KiB
Markdown
# Git Credentials Quick Start Guide
|
|
|
|
## 🚀 Quick Setup (Choose One Method)
|
|
|
|
### Method 1: Git Credential Manager (Recommended for Windows)
|
|
```powershell
|
|
# Run the setup script
|
|
cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner
|
|
.\setup-git-credentials.ps1
|
|
|
|
# Choose option 1 (Git Credential Manager)
|
|
```
|
|
|
|
**What it does:**
|
|
- Installs Microsoft's Git Credential Manager
|
|
- Configures Git to use it
|
|
- Opens browser for authentication
|
|
- Securely stores credentials
|
|
|
|
### Method 2: SSH Keys (Most Secure)
|
|
```powershell
|
|
# Run the setup script
|
|
cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner
|
|
.\setup-git-credentials.ps1
|
|
|
|
# Choose option 3 (SSH Keys)
|
|
```
|
|
|
|
**What it does:**
|
|
- Generates SSH key pair
|
|
- Shows public key to add to git.d-popov.com
|
|
- Changes remote URL to SSH
|
|
- Enables passwordless authentication
|
|
|
|
### Method 3: Personal Access Token
|
|
```powershell
|
|
# Run the setup script
|
|
cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner
|
|
.\setup-git-credentials.ps1
|
|
|
|
# Choose option 4 (Personal Access Token)
|
|
```
|
|
|
|
**What it does:**
|
|
- Configures Git to store credentials
|
|
- Next push/pull will prompt for token
|
|
- Remembers credentials for future use
|
|
|
|
## 🧪 Test Your Setup
|
|
|
|
```powershell
|
|
# Test script
|
|
cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner
|
|
.\test-git-credentials.ps1
|
|
```
|
|
|
|
This will:
|
|
- ✅ Check your credential configuration
|
|
- ✅ Test Git operations
|
|
- ✅ Provide troubleshooting tips
|
|
- ✅ Show SSH key status (if using SSH)
|
|
|
|
## 🔧 Manual Commands (If Needed)
|
|
|
|
### Clear Stored Credentials
|
|
```bash
|
|
# Clear all stored credentials
|
|
git config --global --unset credential.helper
|
|
git config --global credential.helper store # Reset to basic store
|
|
|
|
# Or clear specific credentials
|
|
git config --global --unset-all credential.helper
|
|
```
|
|
|
|
### Change Remote URL
|
|
```bash
|
|
# Check current remote
|
|
git remote -v
|
|
|
|
# Change to SSH (if you have SSH keys)
|
|
git remote set-url origin git@git.d-popov.com:popov/mines.git
|
|
|
|
# Change back to HTTPS
|
|
git remote set-url origin https://git.d-popov.com/popov/mines.git
|
|
```
|
|
|
|
### SSH Key Setup (Manual)
|
|
```bash
|
|
# Generate SSH key
|
|
ssh-keygen -t ed25519 -C "your-email@example.com"
|
|
|
|
# Start SSH agent
|
|
eval "$(ssh-agent -s)"
|
|
ssh-add ~/.ssh/id_ed25519
|
|
|
|
# Copy public key to clipboard (Windows)
|
|
type %USERPROFILE%\.ssh\id_ed25519.pub | clip
|
|
|
|
# Test SSH connection
|
|
ssh -T git@git.d-popov.com
|
|
```
|
|
|
|
## 🚨 Troubleshooting
|
|
|
|
### VS Code Still Asks for Credentials
|
|
1. **Check credential helper:**
|
|
```bash
|
|
git config --global credential.helper
|
|
```
|
|
|
|
2. **Clear VS Code's Git cache:**
|
|
- VS Code: `Ctrl+Shift+P` → "Git: Clear Credentials"
|
|
|
|
3. **Reset Git configuration:**
|
|
```bash
|
|
git config --global --unset credential.helper
|
|
# Then run setup script again
|
|
```
|
|
|
|
### SSH Connection Issues
|
|
```bash
|
|
# Test SSH connection
|
|
ssh -T git@git.d-popov.com
|
|
|
|
# Debug SSH
|
|
ssh -v git@git.d-popov.com
|
|
|
|
# Check SSH agent
|
|
ssh-add -l
|
|
```
|
|
|
|
### Permission Denied
|
|
- ✅ Check if SSH key is added to git.d-popov.com
|
|
- ✅ Verify SSH key has correct permissions (600)
|
|
- ✅ Make sure you're using the correct username
|
|
|
|
### Authentication Failed
|
|
- ✅ Verify Personal Access Token hasn't expired
|
|
- ✅ Check if token has correct permissions
|
|
- ✅ Try regenerating the token
|
|
|
|
## 📋 For git.d-popov.com Server
|
|
|
|
### Generate Personal Access Token:
|
|
1. Log into git.d-popov.com web interface
|
|
2. Go to User Settings → Access Tokens
|
|
3. Create new token with `read/write` permissions
|
|
4. Copy token (you won't see it again!)
|
|
|
|
### Add SSH Key:
|
|
1. Log into git.d-popov.com web interface
|
|
2. Go to User Settings → SSH Keys
|
|
3. Paste your public key (`id_ed25519.pub`)
|
|
4. Save and test: `ssh -T git@git.d-popov.com`
|
|
|
|
## 🔐 Security Best Practices
|
|
|
|
- ✅ **SSH Keys**: Most secure, no passwords stored
|
|
- ✅ **Git Credential Manager**: Secure storage with encryption
|
|
- ⚠️ **Store Credentials**: Plain text (avoid on shared computers)
|
|
- ✅ **Personal Access Tokens**: Time-limited, can be revoked
|
|
- ✅ **Regular Rotation**: Change tokens/keys periodically
|
|
|
|
## 📞 Need Help?
|
|
|
|
1. Run the test script: `.\test-git-credentials.ps1`
|
|
2. Check VS Code Git output panel for errors
|
|
3. Verify your Git server configuration
|
|
4. Try different authentication methods
|
|
|
|
**Quick Fix:** Run `.\setup-git-credentials.ps1` and choose option 1 (GCM) - it usually solves most issues! 🎯
|