A terminal UI for managing git personas β switch between git identities with ease.
Built with Ink for a beautiful interactive CLI experience.
If you work across multiple organisations, contribute to open source, or manage side projects, you probably juggle different git identities. Manually running git config every time is tedious and error-prone.
git-personas lets you define named identities and switch between them instantly β including GPG signing keys, SSH keys, and default branch preferences.
- Interactive TUI β Create, edit, delete, and switch personas with a beautiful terminal UI (no manual config editing)
- Path-based auto-switch β Automatically apply the right persona based on directory patterns (e.g.,
~/work/**,~/personal/**) - Safety features β
statuscommand shows your effective identity,diffcompares personas,pinlocks a persona to a specific repo - Atomic writes with backups β Your
~/.gitconfigis never corrupted; automatic backups keep last 10 versions - Sticky personas β Hooks remember which persona you used per-repo (optional)
- Shell prompt integration β See your active persona in bash/zsh/Starship prompts
- Full CLI toolbox β
switch,list,status,diff,pin,export,import,uninstall - No manual editing β Manage everything through the TUI or CLI commands
While gitinclude is just a Git feature, git-personas is a complete identity management layer on top.
npm install -g git-personasRequirements: Node.js 18+
git-personasYou'll see the main menu with all your personas listed and the currently active one highlighted.
Your existing git identity is automatically imported as the "default" persona on first launch.
- Select β Create Persona to add more
- Fill in a name (e.g.
work,personal,opensource) - Enter your git user name and email
- Optionally pick a GPG signing key (auto-detected from your system)
- Optionally pick an SSH key (auto-detected from
~/.ssh) - Optionally set a default branch name (e.g.
main) - Confirm and you're done
Then switch to it with π Switch Persona.
- Create personas with name, email, GPG key, SSH key, and default branch
- Edit any field on an existing persona
- Delete personas you no longer need
- Switch between personas β uses git's native
includeIffor non-destructive config - Clear your active persona (removes managed section from global config)
- Auto-detection of GPG and SSH keys from your system
- Auto-import of existing git profile on first launch
- π Sticky personas β auto-switch identity per repo via global git hooks
- πͺ Pre-push hook β warns if you're pushing with a different identity than your active persona
- π€ Export/Import β share personas across machines
- β‘ Headless CLI β switch personas from the command line without the TUI
- π₯οΈ Shell Prompt β show active persona in bash, zsh, or Starship
- π§Ή Self-cleanup β hooks remove themselves if git-personas is uninstalled
- ποΈ Uninstall β complete removal of all config, hooks, and shell integrations
In addition to the interactive TUI, you can use git-personas from the command line:
# Launch the interactive TUI (no args)
git-personas
# Switch persona without opening the TUI
git-personas switch work
# List all configured personas
git-personas list
# Show current git identity and active persona
git-personas status
# Pin a persona to the current repo (local override)
git-personas pin work
# Compare two personas
git-personas diff work personal
# Export personas to a file (or stdout)
git-personas export
git-personas export ~/my-personas.json
# Import personas from a file
git-personas import ~/my-personas.json
# Completely remove all git-personas config
git-personas uninstall
# Show help
git-personas --help| Command | Description |
|---|---|
git-personas |
Launch the interactive TUI |
git-personas switch <name> |
Switch to a persona |
git-personas list |
List all configured personas |
git-personas status |
Show current git identity and active persona |
git-personas pin <name> |
Pin a persona to the current repo (local override) |
git-personas diff <a> <b> |
Compare two personas |
git-personas export [file] |
Export personas to JSON file or stdout |
git-personas import <file> |
Import personas from a JSON file |
git-personas uninstall |
Remove all git-personas config |
git-personas --help |
Show help message |
You can also use git-persona (singular) which installs as a git subcommand:
# After installing, these work:
git persona switch work
git persona status
git persona listThis works automatically once git-personas is installed and on your PATH.
Share personas across machines or back them up:
# Export to file
git-personas export ~/backup/personas.json
# Export to stdout (pipe to other tools)
git-personas export | jq '.[].name'
# Import from file (merges with existing personas)
git-personas import ~/backup/personas.jsonImport skips personas with duplicate names. In a TTY, you'll be prompted to rename or skip. In non-TTY mode, duplicates are silently skipped.
Sticky personas automatically manage your git identity on a per-repo basis using global git hooks.
- First commit in a repo β you're prompted to select which persona to use
- Returning to a repo β your saved persona is applied automatically, no prompts
- Persona changed since last use β you get a warning with the changed fields and must confirm
- Only one persona β auto-applied with a notification, no interaction needed
- Non-TTY contexts (CI, IDEs, editors) β silently skipped, never blocks your workflow
- Run
git-personas - Select π Sticky Personas from the main menu
- Select β Enable Sticky Personas
This installs global hooks (pre-commit + pre-push) at ~/.config/git-personas/hooks/ and sets core.hooksPath in your global git config.
- Run
git-personas - Select π Sticky Personas from the main menu
- Select β Disable Sticky Personas
This removes the hooks directory and unsets core.hooksPath.
When sticky personas are enabled, a pre-push hook checks if the identity you're pushing with matches your active persona. If there's a mismatch, you'll be warned and asked to confirm before the push proceeds.
Show your active persona in your terminal prompt. Three integrations are available:
- Run
git-personas - Select π₯οΈ Shell Prompt Integration from the Sticky Personas menu
- Toggle Bash (~/.bashrc)
This adds source ~/.config/git-personas/git-personas.bash to your ~/.bashrc. The result is cached for 30 seconds to avoid reading the file on every prompt redraw.
Note: If you use Starship, the bash PS1 approach won't work β use the Starship integration below instead.
- Run
git-personas - Select π₯οΈ Shell Prompt Integration from the Sticky Personas menu
- Toggle Zsh (~/.zshrc)
This adds source ~/.config/git-personas/git-personas.zsh to your ~/.zshrc. Use $(git_personas_prompt_info) in your PROMPT. For example, with the robbyrussell theme:
PROMPT='%F{blue}%~%f $(git_personas_prompt_info)%F{yellow}%(?:β :β )%f 'This will show π€ persona-name when a persona is active. The result is cached for 30 seconds. Works with or without oh-my-zsh.
- Run
git-personas - Select π₯οΈ Shell Prompt Integration from the Sticky Personas menu
- Toggle β Starship
This adds a [custom.git_persona] module to your ~/.config/starship.toml. It uses a fast sed-based extraction script (no Python or heavy dependencies) and works with any shell that uses Starship.
π‘ Tip: If you use Starship as your prompt, use this integration instead of Bash or Zsh β Starship takes over PS1 and the shell-specific integrations won't have any effect.
| Field | Required | Description |
|---|---|---|
| Name | β | Identifier for the persona (e.g. work, personal) |
| User | β | Git user.name β your display name in commits |
| β | Git user.email β your email in commits |
|
| GPG Key | β | Signing key for verified commits (picked from auto-detected list) |
| SSH Key | β | SSH identity for git over SSH (picked from auto-detected list) |
| Default Branch | β | Sets init.defaultBranch (e.g. main, develop) |
When you switch personas, git-personas writes a per-persona config file and adds an includeIf block to your ~/.gitconfig:
# === BEGIN git-personas managed config ===
# Active persona: work
# Managed by git-personas β do not edit between markers
[includeIf "gitdir:~/"]
path = ~/.config/git-personas/personas/work.config
# === END git-personas managed config ===
The per-persona config file at ~/.config/git-personas/personas/<name>.config contains:
[user]
name = Your Name
email = you@example.com
signingkey = <gpg key id> (if set)
[commit]
gpgsign = true (if GPG key set)
[core]
sshCommand = ssh -i <key path> (if SSH key set)
[init]
defaultBranch = <branch name> (if set)
π‘ Tip: Using
includeIfis non-destructive β your existing~/.gitconfigentries outside the managed section are untouched. Per-repo overrides (set withgit config --local) always take precedence.
If you need a specific repo to always use a certain identity regardless of your active persona, use local config:
git config --local user.email "special@example.com"Local config always wins over global.
When setting up GPG signing, make sure your GPG key's email matches the email in your persona. Otherwise GitHub/GitLab won't show the verified badge on your commits.
If different organisations require different SSH keys, add the SSH key to each persona. git-personas sets core.sshCommand to route SSH through the right key automatically.
Run git-personas β the main screen shows your active persona with a π’ indicator. Or check directly:
git config --global user.name && git config --global user.emailgit-personas export ~/backup/personas.json- β/β β Navigate menu items
- Enter β Select
- Esc β Go back (on any screen, including the main menu which quits)
- In text input fields, Enter advances to the next step
# Clone the repo
git clone https://github.com/PhillOliver-Dev/git-personas.git
cd git-personas
# Install dependencies
npm install
# Run in dev mode
npm run dev
# Typecheck
npm run typecheck
# Lint
npm run lint
# Lint + typecheck
npm run check
# Build
npm run build| Script | Description |
|---|---|
npm run dev |
Run in development mode with tsx |
npm run build |
Compile TypeScript to dist/ + copy shell scripts |
npm run lint |
Lint source files |
npm run lint:fix |
Lint and auto-fix issues |
npm run typecheck |
TypeScript type checking |
npm run check |
Typecheck + lint (runs on pre-commit) |
npm run prepublishOnly |
Check + build (runs automatically before publish) |
- Persona data is stored in
~/.config/git-personas/personas.json - Each persona has a config file at
~/.config/git-personas/personas/<name>.config - On switch, an
includeIfblock in~/.gitconfigpoints to the active persona's config - GPG keys are auto-detected by running
gpg --list-keys --with-colons - SSH keys are auto-detected by scanning
~/.ssh/forid_*files - Global hooks (pre-commit + pre-push) live at
~/.config/git-personas/hooks/
| File | Description |
|---|---|
~/.config/git-personas/personas.json |
Persona definitions + active state |
~/.config/git-personas/personas/*.config |
Per-persona git config files |
~/.config/git-personas/repo-personas.json |
Repoβpersona sticky mappings |
~/.config/git-personas/hooks/pre-commit |
Global pre-commit hook |
~/.config/git-personas/hooks/pre-push |
Global pre-push hook |
~/.config/git-personas/git-personas.bash |
Bash prompt snippet |
~/.config/git-personas/git-personas.zsh |
Zsh prompt snippet |
~/.config/git-personas/git-personas-starship.sh |
Starship persona extraction script |
~/.config/starship.toml |
Managed [custom.git_persona] section (if Starship integration enabled) |
~/.gitconfig |
Managed includeIf section (between markers) |
Remove all git-personas configuration, hooks, and shell integrations:
git-personas uninstallThis removes:
- The managed section from
~/.gitconfig - Global git hooks and
core.hooksPath - Shell prompt integrations (bash, zsh, and Starship)
- The entire
~/.config/git-personas/directory (personas, configs, hooks, scripts)
After running the uninstall command, remove the CLI itself:
npm uninstall -g git-personasMIT