git-context
v1.1.0
Published
Secure CLI to manage multiple GitHub/GitLab accounts with per-folder git credentials
Maintainers
Readme
git-context
🔐 Secure CLI to manage multiple GitHub/GitLab accounts with per-folder git credentials
Why?
If you work with multiple GitHub/GitLab accounts (personal, work, client projects), managing different credentials for each repository can be painful. git-context solves this by:
- ✅ Storing multiple git profiles securely in the cloud
- ✅ Applying per-folder git configurations
- ✅ Cloning repositories without credential prompts
- ✅ Encrypting sensitive tokens locally
- ✅ Never touching your global git config
Installation
npm install -g git-contextQuick Start
# 1. Login to your account
lexa login
# 2. Create a git profile
lexa git setup my-personal-account
# 3. Clone a repo using your profile (no credential prompts!)
lexa clone https://github.com/user/repo.git -p my-personal-account
# 4. Or apply profile to an existing repo
cd ~/projects/my-personal-project
lexa git use my-personal-account
# That's it! Your repo now uses the correct identity.Activity Logging
Track all your lexa actions with detailed logs.
lexa logs
View recent activity logs including actions, profiles used, and time.
# View recent logs
lexa logs
# View logs from last 2 days
lexa logs --days 2
# View last 10 entries
lexa logs --last 10
# Clear all logs
lexa logs --clearOutput:
Date/Time │ Action │ Profile │ Details
───────────────────────────────────────────────────────────────────────────────────
01/01/26 20:15 IST │ git use │ om-ghante │ Applied to /path/repo
01/01/26 20:10 IST │ clone │ om-ghante │ github.com/user/repo
01/01/26 19:45 IST │ init │ work │ /home/user/project
01/01/26 18:00 IST │ login │ - │ [email protected]Natural Language Interface
You can simply type what you want to do in plain English!
lexa "init repo in /my/folder with github.com/user/repo"
lexa "clone github.com/user/repo using work"
lexa "list my profiles"
lexa "use personal profile here"Commands
Authentication
lexa login
Authenticate with your lexa account using email and password.
lexa loginOptions:
- Create a new account or login with existing account
- Email and password authentication via Firebase
lexa logout
Clear stored credentials and logout from the current session.
lexa logoutlexa whoami
Display information about the currently logged-in user.
lexa whoamiOutput:
Current User
Email: [email protected]
User ID: abc123...
Session expires: 1/2/2026, 10:30:00 AMlexa status
Show overall status including authentication state and current git context.
lexa statusOutput:
lexa Status
[OK] Authenticated
Email: [email protected]
[OK] In git repository
Root: /home/user/projects/my-repo
Local config:
user.name = your-username
user.email = [email protected]
Active profile: personalCloning Repositories
lexa clone <repository-url>
Clone a repository using stored credentials. No more credential prompts!
# Interactive: prompts you to select a profile
lexa clone https://github.com/user/repo.git
# Specify profile directly
lexa clone https://github.com/user/repo.git --profile my-work-account
lexa clone https://github.com/user/repo.git -p my-work-account
# Clone to a custom directory
lexa clone https://github.com/user/repo.git -d my-folder
# Combine options
lexa clone https://github.com/user/private-repo.git -p work -d project-folderOptions:
| Option | Alias | Description |
|--------|-------|-------------|
| --profile <name> | -p | Profile to use for cloning |
| --directory <path> | -d | Directory to clone into |
How it works:
- Fetches credentials from the selected profile
- Injects username:PAT into the clone URL
- Clones without asking for credentials
- Automatically applies the profile (user.name, user.email)
- Configures credential helper for future push/pull
Git Profiles
lexa git setup [profile-name]
Create a new git profile or update an existing one.
# Interactive mode
lexa git setup
# Create/update a specific profile
lexa git setup my-work-accountYou'll be prompted for:
| Field | Description |
|-------|-------------|
| Profile Name | Unique identifier for this profile (e.g., work, personal) |
| Provider | GitHub, GitLab, Bitbucket, or Other |
| Username | Your git username |
| Email | Email address for git commits |
| Personal Access Token (PAT) | For HTTPS authentication (stored encrypted) |
| SSH Key Path | Optional path to SSH private key |
Example:
$ lexa git setup personal
Git Profile Setup
? Profile name: personal
? Git provider: GitHub
? Git username: john-doe
? Git email: [email protected]
? Personal Access Token (PAT): ********
? SSH private key path (optional):
[OK] Profile "personal" saved successfully!
To use this profile in a git repository:
lexa git use personallexa git use <profile-name>
Apply a git profile to the current repository.
cd ~/projects/my-repo
lexa git use personalWhat it does:
- Sets
git config --local user.nameanduser.email - Configures credential helper with your PAT
- Configures SSH key (if specified in profile)
- Saves profile info to
.gitcontext/folder
Example:
$ lexa git use personal
Apply Git Profile
Repository: /home/user/projects/my-repo
Fetching profile...
Applying configuration...
[OK] user.name = john-doe
[OK] user.email = [email protected]
[OK] HTTPS credentials configured for github.com
[OK] Saved to .gitcontext/
[OK] Profile "personal" applied successfully!
Provider: github
Username: john-doe
Email: [email protected]
[OK] Git push/pull will now use your stored credentials automatically!lexa git list
List all your saved git profiles.
lexa git list
# Alias:
lexa git lsExample:
$ lexa git list
Your Git Profiles
Fetching profiles...
Found 2 profile(s):
1. personal
Provider: github
Username: john-doe
Email: [email protected]
Token: ******** (stored)
Created: Dec 28, 2025, 11:04 PM
2. work
Provider: github
Username: john-work
Email: [email protected]
Token: ******** (stored)
Created: Dec 20, 2025, 04:43 PM
--------------------------------------------------
Commands:
Use a profile: lexa git use <name>
Update a profile: lexa git setup <name>
Remove a profile: lexa git remove <name>lexa git remove <profile-name>
Delete a git profile permanently.
lexa git remove old-account
# Alias:
lexa git rm old-accountExample:
$ lexa git remove old-account
Remove Git Profile
? Are you sure you want to delete profile "old-account"? Yes
[OK] Profile "old-account" deleted successfully!How It Works
Profiles stored in Firebase: Your profiles are stored securely in Firebase Firestore, so you can access them from any machine.
Local git config only: When you run
lexa git use, it setsgit config --localvalues, affecting only that repository.Credential-embedded cloning:
lexa cloneinjects your PAT into the clone URL (https://user:[email protected]/...), so Git never prompts for credentials.Encrypted tokens: PAT tokens are encrypted using AES-256-GCM before storage.
.gitcontext/folder: Each repo gets a.gitcontext/folder (auto-added to.gitignore) containing the active profile info.
SSH Key Setup
For SSH authentication with multiple accounts:
Generate separate SSH keys:
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_personal -C "[email protected]" ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_work -C "[email protected]"Add the public keys to GitHub/GitLab
When creating profiles, specify the SSH key path:
lexa git setup personal # When prompted for SSH key, enter: ~/.ssh/id_ed25519_personallexa git usewill configurecore.sshCommandfor that repo
Security
- 🔒 No global git config changes - Only
--localconfiguration - 🔒 Encrypted token storage - AES-256-GCM with machine-derived keys
- 🔒 Firebase Auth - Secure authentication with ID tokens
- 🔒 Owner-only access - Firestore rules restrict profile access
- 🔒 Credentials not logged - PAT is masked in clone URLs during display
Examples
Clone a private repo without credential prompts
# First, set up a profile with your PAT
lexa git setup work
# Now clone any private repo
lexa clone https://github.com/company/private-repo.git -p work
# Done! No username/password prompts
cd private-repo
git pull # Works automatically!Switching between accounts
# Work on personal project
cd ~/personal/my-app
lexa git use personal
git commit -m "Personal commit"
git push # Uses personal credentials
# Switch to work project
cd ~/work/company-app
lexa git use work
git commit -m "Work commit"
git push # Uses work credentialsChecking current status
lexa status
# Shows:
# ✓ Authenticated ([email protected])
# ✓ In git repository
# Local config: user.name = your-username
# Active profile: personalTroubleshooting
"Not logged in"
Run lexa login to authenticate first.
"Not a git repository"
The lexa git use command must be run inside a git repository. Use git init or clone a repo first.
"Profile not found"
Run lexa git list to see available profiles. Profile names are case-sensitive.
"Clone still asks for credentials"
Make sure your profile has a PAT (Personal Access Token) stored. Update it with:
lexa git setup <profile-name>Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Repository: https://github.com/om-ghante/git-context.npmpkg
License
MIT © Om Ghante
