git-identity-cli-tool
v0.1.0
Published
CLI tool to manage multiple git identities and SSH keys
Readme
Git Identity Manager
A CLI tool to effortlessly manage multiple Git identities and SSH keys. Switch between work, personal, and other accounts with a single command.
Features
- 🔑 Automatic Key Generation: Generates Ed25519 SSH keys automatically.
- ⚙️ SSH Config Management: Updates
~/.ssh/configwith convenient aliases. - 🔄 Context Switching: Sets local git user/email and updates remote URLs to match the correct SSH key alias.
- 📋 Easy Listing: View all configured identities.
Installation
From NPM (Recommended)
npm install -g git-identity-managerFrom Source
- Clone the repository:
git clone https://github.com/yourusername/git-identity.git - Install dependencies:
cd git-identity npm install - Build and link:
npm run build npm link
Usage
1. Add a New Identity
git-identity addFollow the interactive prompts to create a new identity (e.g., 'work').
- Generates a new SSH key.
- Adds an alias to
~/.ssh/config(e.g.,github.com-work). - Copies the public key to your clipboard.
2. Configure a Repository
Navigate to your git repository and switch to the desired identity:
cd /path/to/repo
git-identity use workThis will:
- Set
git config user.nameanduser.emailfor this repo. - Update
originremote URL to use thegithub.com-workalias.
3. Check Status
See which identity is currently active in your repository:
git-identity current4. List Identities
See all configured identities:
git-identity listHow It Works
The tool uses SSH config aliases to manage multiple keys.
When you run git-identity add, it creates an entry in ~/.ssh/config:
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_work
IdentitiesOnly yesWhen you run git-identity use work, it updates your repo's remote URL:
[email protected]:user/repo.git -> [email protected]:user/repo.git
This ensures the correct SSH key is always used for push/pull operations.
License
ISC
