Stop committing with the wrong email! Switch Git identities instantly.
git-swap is a lightweight, zero-dependency CLI tool written in Go. It allows developers to manage multiple Git identities (Personal, Work, Freelance) and switch between them on a per-project basis with a single command.
It handles not just user.name and user.email, but also manages project-specific SSH keys (core.sshCommand), ensuring you never get "Permission denied" errors again.
- โก๏ธ Instant Switch: Change identity locally for the current repository without affecting global settings.
- ๐ SSH Key Management: Automatically sets specific SSH keys for specific profiles.
- ๐ Commit Signing: Supports GPG and SSH signing keys. Auto-enables signing per profile.
- ๐ CLI Managed: No manual JSON editing needed. Add, edit, and remove profiles interactively.
- ๐ Status Check: Verify which profile is currently active in your repo.
- ๐ฆ Cross-Platform: Works on macOS, Linux, and Windows.
Install via the automatic script:
curl -sL https://raw.githubusercontent.com/abdozkaya/git-swap/main/install.sh | bashRun as Administrator:
iwr -useb https://raw.githubusercontent.com/abdozkaya/git-swap/main/install.ps1 | iexIf you prefer to build it yourself:
git clone https://github.com/abdozkaya/git-swap.git
cd git-swap
go build -o git-swap main.go
sudo mv git-swap /usr/local/bin/The tool is interactive. You can add a new identity (e.g., "work") easily.
git-swap add workIt will ask for:
- Name,
- Email,
- SSH Key Path (Optional: e.g.,
~/.ssh/id_work), - Signing Key (Optional: GPG Key ID or SSH Public Key path for verified commits)
See all your configured identities.
git-swap listNavigate to any git repository and apply a profile.
cd ~/my-company-project
git-swap workOutput: โ Swapped to: work
Not sure which identity is active in the current folder?
git-swap statusUpdate an existing profile or delete one.
git-swap edit workgit-swap remove workgit-swap stores your profiles in a local configuration file (~/.git-swap-config.json).
When you run git-swap <profile>, it executes the following git commands locally in your project:
git config --local user.name "Your Name"
git config --local user.email "email@company.com"
# If SSH Key is provided:
git config --local core.sshCommand "ssh -i /path/to/private_key -F /dev/null"
# If Signing Key is provided:
git config --local user.signingkey "key_id_or_pub_key"
git config --local commit.gpgsign trueThis ensures your global git configuration (~/.gitconfig) remains untouched and clean.
Pull requests are welcome! Feel free to open an issue for any bugs or feature requests.
MIT