Skip to content

omghante/git-context.npmpkg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

git-context

πŸ” Secure CLI to manage multiple GitHub/GitLab accounts with per-folder git credentials

npm version License: MIT

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-context

Quick 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 --clear

Output:

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        β”‚ -            β”‚ omghante@gmail.com

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 login

Options:

  • 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 logout

lexa whoami

Display information about the currently logged-in user.

lexa whoami

Output:

Current User
Email: yourname@email.com
User ID: abc123...
Session expires: 1/2/2026, 10:30:00 AM

lexa status

Show overall status including authentication state and current git context.

lexa status

Output:

lexa Status

[OK] Authenticated
  Email: yourname@email.com

[OK] In git repository
  Root: /home/user/projects/my-repo
  Local config:
    user.name = your-username
    user.email = your@email.com
  Active profile: personal

Cloning 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-folder

Options:

Option Alias Description
--profile <name> -p Profile to use for cloning
--directory <path> -d Directory to clone into

How it works:

  1. Fetches credentials from the selected profile
  2. Injects username:PAT into the clone URL
  3. Clones without asking for credentials
  4. Automatically applies the profile (user.name, user.email)
  5. 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-account

You'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: john@email.com
? 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 personal

lexa git use <profile-name>

Apply a git profile to the current repository.

cd ~/projects/my-repo
lexa git use personal

What it does:

  1. Sets git config --local user.name and user.email
  2. Configures credential helper with your PAT
  3. Configures SSH key (if specified in profile)
  4. 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 = john@email.com
  [OK] HTTPS credentials configured for github.com
  [OK] Saved to .gitcontext/

[OK] Profile "personal" applied successfully!

Provider: github
Username: john-doe
Email: john@email.com

[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 ls

Example:

$ lexa git list

Your Git Profiles

Fetching profiles...

Found 2 profile(s):

  1. personal
     Provider: github
     Username: john-doe
     Email:    john@email.com
     Token:    ******** (stored)
     Created:  Dec 28, 2025, 11:04 PM

  2. work
     Provider: github
     Username: john-work
     Email:    john@company.com
     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-account

Example:

$ 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

  1. Profiles stored in Firebase: Your profiles are stored securely in Firebase Firestore, so you can access them from any machine.

  2. Local git config only: When you run lexa git use, it sets git config --local values, affecting only that repository.

  3. Credential-embedded cloning: lexa clone injects your PAT into the clone URL (https://user:token@github.com/...), so Git never prompts for credentials.

  4. Encrypted tokens: PAT tokens are encrypted using AES-256-GCM before storage.

  5. .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:

  1. Generate separate SSH keys:

    ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_personal -C "personal@email.com"
    ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_work -C "work@email.com"
  2. Add the public keys to GitHub/GitLab

  3. When creating profiles, specify the SSH key path:

    lexa git setup personal
    # When prompted for SSH key, enter: ~/.ssh/id_ed25519_personal
  4. lexa git use will configure core.sshCommand for that repo


Security

  • πŸ”’ No global git config changes - Only --local configuration
  • πŸ”’ 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 credentials

Checking current status

lexa status
# Shows:
# βœ“ Authenticated (email@example.com)
# βœ“ In git repository
#   Local config: user.name = your-username
#   Active profile: personal

Troubleshooting

"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

About

"A secure CLI to manage and switch between multiple GitHub and GitLab accounts using centralized credentials."

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors