|
| 1 | +# Git Credential Manager Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +SourceGit now includes comprehensive Git credential management to solve the common problem on Linux (and other platforms) where users have to repeatedly enter their credentials for each Git operation. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +### Automatic Detection |
| 10 | +- **Auto-discovery**: Automatically detects available credential helpers on your system |
| 11 | +- **Smart Selection**: Chooses the most secure available option by default |
| 12 | +- **Cross-platform**: Works on Windows, macOS, and Linux with platform-specific optimizations |
| 13 | + |
| 14 | +### Supported Credential Helpers |
| 15 | + |
| 16 | +#### 1. **None** |
| 17 | +- No credential storage |
| 18 | +- Will prompt for credentials each time |
| 19 | +- Most secure but least convenient |
| 20 | + |
| 21 | +#### 2. **Git Credential Manager (GCM)** |
| 22 | +- Cross-platform credential manager from Microsoft |
| 23 | +- Supports multi-factor authentication |
| 24 | +- Works with GitHub, Azure DevOps, Bitbucket, and more |
| 25 | +- **Recommended for most users** |
| 26 | + |
| 27 | +#### 3. **Cache** |
| 28 | +- Stores credentials in memory temporarily |
| 29 | +- Default timeout: 1 hour |
| 30 | +- Good balance of security and convenience |
| 31 | +- No persistent storage on disk |
| 32 | + |
| 33 | +#### 4. **Store** |
| 34 | +- Saves credentials to a file on disk |
| 35 | +- **Warning**: Stores passwords in plain text |
| 36 | +- Only use on secure, single-user systems |
| 37 | +- File location: `~/.sourcegit/data/.git-credentials` |
| 38 | + |
| 39 | +#### 5. **Platform-Specific Options** |
| 40 | + |
| 41 | +##### Linux: Libsecret |
| 42 | +- Integrates with GNOME Keyring or KWallet |
| 43 | +- Secure encrypted storage |
| 44 | +- Automatically unlocked when you log in |
| 45 | +- **Recommended for Linux desktop users** |
| 46 | + |
| 47 | +##### macOS: Keychain |
| 48 | +- Uses the native macOS Keychain |
| 49 | +- Secure, encrypted storage |
| 50 | +- Integrated with system security |
| 51 | +- **Recommended for macOS users** |
| 52 | + |
| 53 | +##### Windows: Windows Credential Store |
| 54 | +- Uses Windows Credential Manager |
| 55 | +- Secure, encrypted storage |
| 56 | +- Integrated with Windows security |
| 57 | +- **Recommended for Windows users** |
| 58 | + |
| 59 | +#### 6. **Custom** |
| 60 | +- Specify your own credential helper command |
| 61 | +- For advanced users with specific requirements |
| 62 | +- Supports any git-credential-* helper |
| 63 | + |
| 64 | +## Configuration |
| 65 | + |
| 66 | +### Via UI |
| 67 | + |
| 68 | +1. Open **Preferences** (Ctrl/Cmd + ,) |
| 69 | +2. Navigate to the **Git** tab |
| 70 | +3. Find the **Credential Helper** dropdown |
| 71 | +4. Select your preferred credential helper |
| 72 | +5. For custom helpers, enter the command in the text field that appears |
| 73 | + |
| 74 | +### Automatic Configuration |
| 75 | + |
| 76 | +SourceGit automatically: |
| 77 | +1. Detects available credential helpers on startup |
| 78 | +2. Selects the most secure available option |
| 79 | +3. Applies the configuration to all Git operations |
| 80 | + |
| 81 | +### Priority Order |
| 82 | + |
| 83 | +When multiple helpers are available, SourceGit selects based on this priority: |
| 84 | +1. Git Credential Manager Core |
| 85 | +2. Git Credential Manager |
| 86 | +3. Libsecret (Linux) |
| 87 | +4. macOS Keychain (macOS) |
| 88 | +5. Windows Credential Store (Windows) |
| 89 | +6. Cache (memory-based) |
| 90 | +7. Store (file-based) |
| 91 | +8. None |
| 92 | + |
| 93 | +## Linux-Specific Setup |
| 94 | + |
| 95 | +### Installing Credential Helpers |
| 96 | + |
| 97 | +#### Ubuntu/Debian |
| 98 | +```bash |
| 99 | +# For Git Credential Manager |
| 100 | +curl -sSL https://aka.ms/gcm/linux-install-source.sh | sh |
| 101 | +git-credential-manager configure |
| 102 | + |
| 103 | +# For Libsecret |
| 104 | +sudo apt-get install libsecret-1-0 libsecret-1-dev |
| 105 | +sudo apt-get install git-credential-libsecret |
| 106 | +``` |
| 107 | + |
| 108 | +#### Fedora/RHEL |
| 109 | +```bash |
| 110 | +# For Git Credential Manager |
| 111 | +curl -sSL https://aka.ms/gcm/linux-install-source.sh | sh |
| 112 | +git-credential-manager configure |
| 113 | + |
| 114 | +# For Libsecret |
| 115 | +sudo dnf install libsecret libsecret-devel |
| 116 | +sudo dnf install git-credential-libsecret |
| 117 | +``` |
| 118 | + |
| 119 | +#### Arch Linux |
| 120 | +```bash |
| 121 | +# For Git Credential Manager |
| 122 | +yay -S git-credential-manager-core-bin |
| 123 | + |
| 124 | +# For Libsecret |
| 125 | +sudo pacman -S libsecret |
| 126 | +sudo pacman -S git-credential-libsecret |
| 127 | +``` |
| 128 | + |
| 129 | +### Troubleshooting Linux Credential Issues |
| 130 | + |
| 131 | +#### Problem: Credentials not persisting |
| 132 | +**Solution**: |
| 133 | +1. Check if a keyring daemon is running: |
| 134 | + ```bash |
| 135 | + ps aux | grep -E 'gnome-keyring|kwallet' |
| 136 | + ``` |
| 137 | +2. If not, start it: |
| 138 | + ```bash |
| 139 | + # For GNOME |
| 140 | + gnome-keyring-daemon --start --daemonize |
| 141 | + |
| 142 | + # For KDE |
| 143 | + kwalletd5 & |
| 144 | + ``` |
| 145 | + |
| 146 | +#### Problem: "No credential helper is configured" |
| 147 | +**Solution**: |
| 148 | +1. Open SourceGit Preferences |
| 149 | +2. Select a credential helper from the dropdown |
| 150 | +3. Restart SourceGit |
| 151 | + |
| 152 | +#### Problem: Libsecret not working |
| 153 | +**Solution**: |
| 154 | +1. Ensure libsecret is installed correctly |
| 155 | +2. Check if the keyring is unlocked |
| 156 | +3. Try using the Cache helper as a fallback |
| 157 | + |
| 158 | +## Security Recommendations |
| 159 | + |
| 160 | +### Best Practices |
| 161 | + |
| 162 | +1. **Use platform-specific secure storage** when available: |
| 163 | + - Linux: Libsecret |
| 164 | + - macOS: Keychain |
| 165 | + - Windows: Credential Store |
| 166 | + |
| 167 | +2. **Avoid the Store helper** unless: |
| 168 | + - You're on a secure, single-user system |
| 169 | + - The repository contains only public data |
| 170 | + - You understand the security implications |
| 171 | + |
| 172 | +3. **Use Cache for temporary access**: |
| 173 | + - Good for shared systems |
| 174 | + - Credentials expire after timeout |
| 175 | + - No persistent storage |
| 176 | + |
| 177 | +4. **Configure timeout for Cache**: |
| 178 | + - Default: 3600 seconds (1 hour) |
| 179 | + - Adjust based on your security needs |
| 180 | + |
| 181 | +### Personal Access Tokens |
| 182 | + |
| 183 | +For enhanced security with services like GitHub: |
| 184 | +1. Use Personal Access Tokens instead of passwords |
| 185 | +2. Generate tokens with minimal required permissions |
| 186 | +3. Set expiration dates on tokens |
| 187 | +4. Store tokens securely using credential helpers |
| 188 | + |
| 189 | +## Implementation Details |
| 190 | + |
| 191 | +### How It Works |
| 192 | + |
| 193 | +1. **Detection Phase**: On startup, SourceGit checks for available credential helpers |
| 194 | +2. **Selection Phase**: Chooses the best available helper based on security and platform |
| 195 | +3. **Configuration Phase**: Sets the credential helper for all Git operations |
| 196 | +4. **Runtime Phase**: Git uses the configured helper for all remote operations |
| 197 | + |
| 198 | +### Technical Architecture |
| 199 | + |
| 200 | +The credential manager system consists of: |
| 201 | +- `Models/CredentialManager.cs`: Core credential manager logic |
| 202 | +- `Views/Preferences.axaml`: UI for credential helper selection |
| 203 | +- `Native/OS.cs`: Platform-specific credential helper integration |
| 204 | +- `Commands/Command.cs`: Git command execution with credential helper |
| 205 | + |
| 206 | +### Git Command Integration |
| 207 | + |
| 208 | +All Git commands executed by SourceGit include: |
| 209 | +```bash |
| 210 | +git -c credential.helper=[selected-helper] [command] |
| 211 | +``` |
| 212 | + |
| 213 | +This ensures consistent credential handling across all operations. |
| 214 | + |
| 215 | +## Frequently Asked Questions |
| 216 | + |
| 217 | +### Q: Why do I still get prompted for credentials? |
| 218 | +**A**: This can happen if: |
| 219 | +- No credential helper is configured |
| 220 | +- The credential helper is not installed properly |
| 221 | +- Your stored credentials have expired |
| 222 | +- You're accessing a new repository/remote |
| 223 | + |
| 224 | +### Q: Is it safe to use the Store helper? |
| 225 | +**A**: The Store helper saves passwords in plain text. Only use it on: |
| 226 | +- Secure, single-user systems |
| 227 | +- Systems with encrypted disk storage |
| 228 | +- For repositories without sensitive data |
| 229 | + |
| 230 | +### Q: Can I use multiple credential helpers? |
| 231 | +**A**: Git supports credential helper chaining, but SourceGit currently configures one helper at a time for simplicity and predictability. |
| 232 | + |
| 233 | +### Q: How do I clear stored credentials? |
| 234 | +**A**: Depends on the helper: |
| 235 | +- **Cache**: Restart SourceGit or wait for timeout |
| 236 | +- **Store**: Delete `~/.git-credentials` or the configured file |
| 237 | +- **Libsecret/Keychain**: Use system tools to manage stored passwords |
| 238 | +- **GCM**: Run `git credential-manager erase` |
| 239 | + |
| 240 | +## Support |
| 241 | + |
| 242 | +If you encounter issues with credential management: |
| 243 | +1. Check the credential helper dropdown in Preferences |
| 244 | +2. Verify the helper is installed correctly |
| 245 | +3. Try a different credential helper |
| 246 | +4. Report issues at: https://github.com/sourcegit-scm/sourcegit/issues |
0 commit comments