@tongmenglaysmae/gitch
v1.0.0
Published
Git account switcher — manage multiple Git identities
Maintainers
Readme
gitch
Switch between multiple Git accounts in seconds. Manage SSH keys, git configs, and GitHub CLI auth per profile.
Why gitch?
Managing multiple Git accounts (work, personal, open source) usually means manually editing ~/.ssh/config, juggling git config --global, and hoping you don't push to the wrong repo with the wrong identity. gitch automates all of this:
- One command to switch —
gitch use worksets your global git identity, SSH routing, and GitHub CLI auth in one shot - Per-directory identities — bind a profile to a directory and it auto-activates when you
cdinto it - SSH key isolation — each profile gets its own SSH host alias with
IdentitiesOnly yes, following GitHub's official best practices - Headless mode — every command works non-interactively for CI, scripts, and AI agents
- Automatic backups — every config change is backed up, and you can restore with
gitch restore
Install
Requires Bun runtime. Until this package is published under a name you control, install from source:
git clone https://github.com/Joselay/gitch.git
cd gitch
bun install
bun linkQuick Start
# Create a profile (interactive)
gitch add work
# Create a profile (headless — for CI/scripts)
gitch add work --name "John Doe" --email "[email protected]" --generate-key
# Switch global identity
gitch use work
# See who you are
gitch whoami
# List all profiles
gitch listCommands
| Command | Description |
|---|---|
| gitch add <profile> | Create a new git profile |
| gitch use <profile> | Switch global git identity |
| gitch whoami | Show active profile |
| gitch list | List all profile names |
| gitch status | Detailed view of profiles and bindings |
| gitch edit <profile> | Edit an existing profile |
| gitch rename <old> <new> | Rename a profile (preserves SSH config and bindings) |
| gitch remove <profile> | Delete a profile |
| gitch bind <profile> [path] | Bind a directory to a profile |
| gitch unbind [path] | Remove a directory binding |
| gitch clone <profile> <repo> | Clone a repo with a profile's SSH routing |
| gitch doctor | Check system health and profile validity |
| gitch restore [backup] | Restore config from a backup |
| gitch init <shell> | Output shell hook for auto-switching |
Directory Bindings
Bind a profile to a directory so it auto-activates when you cd into it:
# Bind current directory
gitch bind work
# Bind a specific path
gitch bind personal ~/projects/side-project
# Remove a binding
gitch unbind ~/projects/side-projectShell Integration
Add auto-switching so gitch applies the correct profile when you cd into a bound directory.
zsh — add to ~/.zshrc:
eval "$(gitch init zsh)"bash — add to ~/.bashrc:
eval "$(gitch init bash)"fish — add to ~/.config/fish/config.fish:
gitch init fish | sourceOnce configured, gitch automatically switches your local git identity when you enter a bound directory.
Headless Mode
All commands work non-interactively for scripts, CI, and AI agents:
# Add profile without prompts
gitch add work \
--name "John Doe" \
--email "[email protected]" \
--ssh-key ~/.ssh/id_ed25519_work \
--gh-username johndoe
# Generate SSH key and add it to GitHub automatically
gitch add deploy --name "Deploy" --email "[email protected]" --generate-key --add-to-github
# Test SSH connection after setup
gitch add work --name "John" --email "[email protected]" --generate-key --test-ssh
# Remove without confirmation
gitch remove old-profile --yesHow It Works
- Profiles are stored in
~/.gitch/config.json - Each profile gets an SSH host alias in
~/.ssh/configwithIdentitiesOnly yes(prevents key conflicts) gitch usesetsgit config --global user.name/email, appliesurl.*.insteadOfrewriting (so existing clones use the correct SSH key), and optionally switchesgh authgitch bindsetsgit config --local user.name/emailfor per-directory identitygitch add --add-to-githubusesgh ssh-key addto register keys programmaticallygitch add --test-sshverifies the SSH connection works after setup- Automatic backups are created before every config change (max 10 retained)
Development
bun install # install dependencies
bun test # run tests
bun run lint # lint with Biome
bun run typecheck # type check
bun run check # lint + typecheck + test (all at once)
bun run build # compile standalone binary to dist/gitchSee CONTRIBUTING.md for more details.
