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.
- 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.
brew tap pavelkortp/tap
brew install git-profilenpm install -g @p-pavlo/git-profileTo see all available commands, run:
git-profile --helpCreate 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]Display all configured profiles. The active global profile and current directory's active local profile will be highlighted:
git-profile listSwitch 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 --globalTo 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)Profiles are stored locally in JSON format at:
~/.git-profiles.json
MIT