Now available on Homebrew as well
GitMorph is a powerful CLI tool that allows you to seamlessly switch between multiple Git identities on your local machine. It ensures that all Git commands use the active profile’s identity and SSH key. Perfect for developers who work on different projects with various Git accounts and want consistent commits across repositories.
From v3+, GitMorph acts as a wrapper for all Git commands in repositories with an active GitMorph profile.
- Any Git command should now be prefixed with
gitmorph. - Examples:
gitmorph add .
gitmorph commit -m "Your commit message"
gitmorph push origin main- This ensures the active profile’s Git identity and SSH key are correctly applied.
- Running plain
gitcommands may bypass the active profile and cause mismatched commits. - Older users please run gitmorph fix once after updating.
⚠️ We highly recommend using a alias like thisalias gim='gitmorph'
- Create and manage multiple Git profiles
- Easily switch between different Git identities (incl. per-profile SSH key)
- List all available profiles (shows SSH key path)
- Edit existing profiles
- Delete profiles
- Repo-specific auto-switch using
.gitmorphfile - Simple and intuitive command-line interface
Make sure you have Go installed, then run:
go install github.com/abhigyan-mohanta/gitmorph@latestor with Homebrew
brew tap abhigyan-mohanta/homebrew-tap
brew install --cask gitmorphAfter installation, add Go binaries to your PATH:
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc
source ~/.zshrcgitmorph newPrompts for:
- Profile name
- Git username
- Git email
- SSH private key path (leave blank for
~/.ssh/id_ed25519) - Set this profile as default? (y/N)
gitmorph listExample output:
Available Git profiles:
NAME USERNAME EMAIL SSH KEY FLAGS
work abhigyan6602 abhigyan@hostagedown.com ~/.ssh/id_ed25519 [default]
personal abhigyan-mohanta underthunder02@gmail.com ~/.ssh/id_ed25519_personal [active]
gitmorph default <profile-name>- Sets the specified profile as the global default.
Example:
gitmorph default personal
# Profile 'personal' is now the default.gitmorph activate <profile-name>- Sets
user.nameanduser.emailglobally - Sets or unsets
core.sshCommandto use the profile’s SSH key - Adds a
.gitmorphfile in the project root to auto-use this profile
gitmorph deactivate- Deactivates the repo-specific profile
- Falls back to the global default profile
Example:
gitmorph deactivate
# Project-specific profile deactivated. Falling back to default profile.
# Switched to profile 'work' (global)gitmorph fix- Repairs
~/.gitmorph.jsonif something went wrong - Reapplies the default profile if needed
Example:
gitmorph fix
# Fixed ~/.gitmorph.json.
# 'personal' is now the default profile.
# Change it using 'gitmorph default <profile>'Recommended for users migrating from v2 to v3+.
gitmorph edit <profile-name>Interactively update:
- Username
- SSH key path
- Default profile flag (current: false)
Leave a prompt blank to keep the current value.
gitmorph delete <profile-name>Removes the profile entry from ~/.gitmorph.json.
If upgrading from GitMorph v2:
- Run
gitmorph fixto migrate your existing configuration - Re-set your default profile using
gitmorph default <profile>if needed - Verify repo-specific profiles with
gitmorph deactivate
You can still use ~/.ssh/config; GitMorph’s core.sshCommand overrides it when set.
Example:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
)Contributions are welcome! Please submit a Pull Request.