@p-pavlo/git-profile
v1.0.1
Published
A lightweight, zero-dependency CLI identity manager to switch Git profiles, SSH keys, GPG keys, and service tokens instantly.
Maintainers
Readme
Git Profile Switcher CLI (git-profile)
A simple, interactive CLI tool to manage and switch between multiple Git profiles (identities, SSH keys, GPG keys, and service credentials) seamlessly.
If you work across different Git profiles (e.g., personal GitHub, corporate GitHub, GitLab accounts), this tool eliminates the need to copy-paste names, emails, keys, and tokens.
Features
- Multi-Identity Management: Define separate profiles with unique names, emails, GPG signing keys, SSH keys, and service usernames.
- Smart Switch Scope:
- Switch locally (
git-profile use <name> --local) to write configurations directly to the repository's.git/config. - Switch globally (
git-profile use <name> --global) to update your global git config. - Automatically runs
--localif you are inside a Git repository, and--globalotherwise.
- Switch locally (
- Conflict-Free SSH Keys: Sets Git's
core.sshCommanddynamically (ssh -i <key_path> -o IdentitiesOnly=yes) inside the repo. This avoids polluting your global~/.ssh/configfile. - Account Separation in Keychain: Configures Git's
credential.https://<host>.username <username>, allowing the macOS Keychain helper (osxkeychain) to store separate API tokens or passwords for different profiles on the same host (e.g.github.com). - Environment Exporting: Inject Personal Access Tokens (like
GITHUB_TOKEN) directly into your current terminal session viaeval $(git-profile env <name>). - Zero External Dependencies: Fast, lightweight, and secure.
Installation
Via Homebrew (macOS)
brew tap pavelkortp/tap
brew install git-profileVia NPM
npm install -g @p-pavlo/git-profileUsage Guide
1. Interactive Help
To see all available commands, run:
git-profile --help2. Add a New Profile
Create a profile interactively. You will be prompted to enter details for user name, email, SSH key path, GPG Key ID, and service token:
git-profile add [profile-name]3. List Profiles
Display all configured profiles. The active global profile and current directory's active local profile will be highlighted:
git-profile list4. Switch Profile
Switch to a specific profile:
# Apply locally to the current git repository (default behavior if inside a repo)
git-profile use work
# Force apply globally (updates ~/.gitconfig)
git-profile use personal --global5. Export Tokens to Shell Session
To inject the profile's personal access token (GITHUB_TOKEN) and git variables into your current shell session (useful for GitHub CLI gh or script execution):
eval $(git-profile env work)Configuration File
Profiles are stored locally in JSON format at:
~/.git-profiles.json
License
MIT
