Synchronization Methods¶
GitBridge provides two methods for synchronizing GitHub repositories, ensuring you can always access your code regardless of network restrictions.
Overview¶
Method | Speed | Requirements | Use Case |
---|---|---|---|
API | Fast ⚡ | GitHub token (for private repos) | Default method, most efficient |
Browser | Slow 🐢 | Modern browser (Chrome/Firefox/Edge) | When API access is blocked |
API Synchronization Method¶
The API method uses GitHub's REST API to efficiently sync repositories.
How It Works¶
sequenceDiagram
participant GitBridge
participant GitHub API
participant Local Files
GitBridge->>GitHub API: Request repository tree
GitHub API-->>GitBridge: Return file list with SHAs
GitBridge->>Local Files: Compare with cached SHAs
GitBridge->>GitHub API: Request changed files only
GitHub API-->>GitBridge: Return file contents
GitBridge->>Local Files: Save updated files
GitBridge->>Local Files: Update metadata cache
Features¶
- Incremental Updates: Only downloads changed files
- Parallel Downloads: Multiple files downloaded simultaneously
- SHA Verification: Ensures file integrity
- Efficient for Large Repos: Minimal bandwidth usage
- Branch/Tag Support: Sync any ref (branch, tag, commit)
Configuration¶
API Rate Limits¶
GitHub API has rate limits:
- Unauthenticated: 60 requests/hour
- Authenticated: 5,000 requests/hour
- GitHub Enterprise: Varies by installation
Avoiding Rate Limits
- Always use authentication token
- Enable incremental mode
- Cache metadata between syncs
- Use
--verbose
to monitor API usage
Advanced Options¶
Browser Automation Method¶
The browser method uses Playwright to automate a real browser, mimicking manual repository browsing.
How It Works¶
sequenceDiagram
participant GitBridge
participant Chrome Browser
participant GitHub Website
participant Local Files
GitBridge->>Browser: Launch browser (Playwright)
Browser->>GitHub Website: Navigate to repository
GitBridge->>Browser: Click "Download ZIP"
Browser->>GitHub Website: Request ZIP file
GitHub Website-->>Browser: Return ZIP data
GitBridge->>Browser: Extract file list from ZIP
GitBridge->>Local Files: Compare with existing files
GitBridge->>Browser: Download changed files
GitBridge->>Local Files: Save updated files
Features¶
- Works Anywhere: If you can browse GitHub, it works
- No API Token Required: Uses browser session
- Handles JavaScript: Works with dynamic content
- Cookie Support: Can use existing browser sessions
- Proxy Aware: Uses browser's proxy settings
Configuration¶
Browser Setup¶
Browser Installation¶
Playwright can automatically install browsers for you:
Browser Management¶
Playwright manages browser binaries automatically. No separate driver installation needed!
Advanced Options¶
Handling Authentication¶
For private repositories with browser method:
-
Manual Login (Recommended for first use):
-
Cookie Reuse:
-
Basic Auth (if supported):
Choosing the Right Method¶
Use API Method When:¶
- ✅ You have network access to api.github.com
- ✅ You need fast synchronization
- ✅ You're syncing large repositories
- ✅ You need incremental updates
- ✅ You're automating syncs
Use Browser Method When:¶
- ✅ API access is blocked by firewall
- ✅ Only browser access to GitHub works
- ✅ You need to handle complex authentication
- ✅ You're syncing occasionally (not time-critical)
- ✅ API rate limits are exhausted
Method Comparison¶
Performance Comparison¶
Aspect | API Method | Browser Method |
---|---|---|
Initial sync (1GB repo) | ~2 minutes | ~15 minutes |
Incremental update | ~5 seconds | ~2 minutes |
Memory usage | Low (50MB) | High (500MB+) |
CPU usage | Low | Medium-High |
Network efficiency | Excellent | Good |
Feature Comparison¶
Feature | API Method | Browser Method |
---|---|---|
Incremental updates | ✅ Yes | ✅ Yes |
Parallel downloads | ✅ Yes | ❌ No |
Large file support | ⚠️ Limited | ✅ Yes |
Authentication | Token | Browser session |
Proxy support | ✅ Yes | ✅ Yes |
Rate limiting | Yes (5k/hour) | No |
JavaScript required | ❌ No | ✅ Yes |
Fallback Strategy¶
Configure automatic fallback from API to browser method:
YAML | |
---|---|
Implementation in code:
Troubleshooting¶
API Method Issues¶
403 Forbidden
- Check your token permissions
- Verify token hasn't expired
- Check API rate limits
Connection Timeout
- Check firewall rules for api.github.com
- Try using proxy configuration
- Verify network connectivity
Browser Method Issues¶
Browser Not Found
- Run
playwright install chromium
- Or specify executable_path explicitly
- Check Playwright installation
Timeout Errors
- Increase timeout values
- Check network speed
- Try non-headless mode for debugging
Best Practices¶
- Start with API method - It's faster and more efficient
- Use browser as fallback - Only when API is blocked
- Enable incremental mode - Save bandwidth and time
- Cache credentials securely - Use environment variables or secure stores
- Monitor rate limits - Use
--verbose
to track API usage - Test both methods - Ensure fallback works before you need it
Next Steps¶
- Learn about Authentication options
- Configure for Corporate Environments
- Set up Proxy Configuration
- Understand Incremental Sync mechanics