wit provides first-class GitHub integration with OAuth authentication, making it easy to clone, push, and pull from GitHub repositories.
Authentication
OAuth Device Flow (Recommended)
The easiest way to authenticate with GitHub:
This will:
- Display a URL and a code
- Open your browser to GitHub
- You enter the code and authorize wit
- wit securely stores your credentials
ℹ Starting GitHub authentication...
Please visit: https://github.com/login/device
Enter code: ABCD-1234
Waiting for authorization...
✓ Logged in as username (user@email.com)
Check Status
See your current authentication status:
Output:
✓ Authenticated as username
Email: user@email.com
Token: ghp_xxxx...xxxx (hidden)
Scopes: repo, user:email
Authenticated: 2 hours ago
Logout
Remove stored credentials:
Get Token (For Scripts)
If you need the token for other tools:
Be careful with this command - it outputs your token in plain text.
Only use in secure environments.
Environment Variables
You can also authenticate using environment variables:
| Variable | Description |
|---|
GITHUB_TOKEN | GitHub personal access token |
GH_TOKEN | Alternative (GitHub CLI compatible) |
WIT_GITHUB_CLIENT_ID | Custom OAuth App client ID |
# Using a personal access token
export GITHUB_TOKEN=ghp_your_token_here
# Now wit commands work without login
wit clone https://github.com/user/private-repo.git
wit push origin main
Creating a Personal Access Token
If you prefer tokens over OAuth:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Click “Generate new token (classic)”
- Select scopes:
repo - Full control of private repositories
user:email - Read user email (for commits)
- Copy the token
- Set it in your environment:
export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
How Authentication Works
Priority Order
wit checks for credentials in this order:
- Environment variables (
GITHUB_TOKEN, GH_TOKEN)
- Stored OAuth credentials (from
wit github login)
- Git credential helpers (system keychain)
Credential Storage
OAuth credentials are stored in:
- macOS/Linux:
~/.wit/github-credentials.json
- Windows:
%USERPROFILE%\.wit\github-credentials.json
The file is created with restricted permissions (readable only by you).
When you authenticate with GitHub, wit automatically uses your GitHub profile for commit author information:
# Before: commits show as "Anonymous"
wit commit -m "message" # Author: Anonymous <anonymous@example.com>
# After wit github login: uses your GitHub info
wit commit -m "message" # Author: Your Name <your@email.com>
Common Workflows
Clone Private Repository
# First, authenticate
wit github login
# Then clone - authentication is automatic
wit clone https://github.com/yourcompany/private-repo.git
Push to GitHub
# Make changes
echo "hello" > file.txt
wit add file.txt
wit commit -m "Add file"
# Push (uses stored credentials)
wit push origin main
Fork Workflow
# Clone your fork
wit clone https://github.com/you/forked-repo.git
cd forked-repo
# Add upstream
wit remote add upstream https://github.com/original/repo.git
# Fetch upstream changes
wit fetch upstream
# Merge upstream into your branch
wit checkout main
wit merge upstream/main
# Push to your fork
wit push origin main
Troubleshooting
”401 Unauthorized”
Your credentials may have expired:
wit github logout
wit github login
“Permission denied”
Check if you have access to the repository:
Make sure your token has the repo scope for private repositories.
Token Not Working
If using a personal access token, verify:
- Token hasn’t expired
- Token has correct scopes (
repo, user:email)
- Token is set correctly:
echo $GITHUB_TOKEN # Should show your token
OAuth Login Fails
If the device flow fails:
- Make sure you’re entering the code correctly
- Try logging out and in again
- Check your internet connection
- As fallback, use a personal access token
Security Best Practices
Do:
- Use OAuth login when possible (tokens are scoped and can be revoked)
- Set restrictive token scopes
- Rotate tokens periodically
- Use
wit github logout on shared machines
Don’t:
- Commit tokens to repositories
- Share tokens in plain text
- Use tokens with more permissions than needed
Custom OAuth App
For enterprise deployments, you can use your own OAuth App:
- Create an OAuth App at github.com/settings/developers
- Set the client ID:
export WIT_GITHUB_CLIENT_ID=your_client_id
wit github login
This is useful for:
- Enterprise GitHub instances
- Custom branding
- Organizational control over OAuth scopes