CLI tool to manage multiple Git identities with automatic GitHub SSH key setup. Use regular git commands with --profile flag.
npm install @guruvedhanth-s/git-id> Development README for the Git Identity Manager CLI package
A CLI tool to manage multiple Git identities with automatic GitHub SSH key setup. Use the regular git command with --profile flag to work with different GitHub accounts.
- Use Regular Git - Just add --profile to any git command
- Multiple Git Profiles - Create and switch between different Git identities
- GitHub OAuth Integration - Sign in with GitHub to auto-configure everything
- Automatic SSH Key Management - Generates and uploads SSH keys to GitHub
- Automatic Shell Configuration - Sets up --profile support on installation
- Profile-based Cloning - Clone repos with the correct identity automatically
---
``bash`
npm i -g @guruvedhanth-s/git-id
That's it! Shell configuration is automatic.
For complete documentation, see:
- Main README - Package overview and quick start
- DOCUMENTATION - Complete usage guide
---
`bashClone the repository
git clone https://github.com/guruvedhanth-s/Git-Identity-Manager.git
cd Git-Identity-Manager/git-id-cli
$3
`bash
Build after changes
npm run buildRun in development mode
npm run devTest the CLI
git-id --version
git-id list
`---
Quick Start
`bash
Create a profile with GitHub sign-in
git-id add --githubList your profiles
git-id listClone with a profile
git clone https://github.com/user/repo.git --profile workCheck current identity
git-id current
`---
Commands Overview
$3
Add
--profile to any git command:`bash
Clone with profile
git clone https://github.com/company/project.git --profile work
git clone https://github.com/personal/repo.git --profile personalPush with profile
git push origin main --profile workPull with profile
git pull --profile personalAny git command works!
git fetch --profile work
git commit -m "message" --profile personal
`$3
`bash
List all profiles
git-id listCreate new profile (with GitHub sign-in)
git-id add --githubCreate new profile (manual)
git-id add --manualSwitch profile in current repo
git-id use work
git-id use personal --global # Apply globallyShow current identity
git-id currentTest SSH connection
git-id test workDelete a profile
git-id delete oldprofile
git-id delete --all # Delete all profiles
`---
Usage Examples
$3
`bash
Create work profile
git-id add --github
→ Name: work
→ Sign in with work GitHub accountCreate personal profile
git-id add --github
→ Name: personal
→ Sign in with personal GitHub accountClone work repository
git clone https://github.com/company/project.git --profile work
cd project
git-id current # Verify: Profile: workClone personal repository
git clone https://github.com/username/my-project.git --profile personal
cd my-project
git-id current # Verify: Profile: personal
`$3
`bash
cd existing-repoCheck current identity
git-id currentSwitch to different profile
git-id use workVerify
git config user.email # Shows work email
`$3
`bash
Setup profiles for each account
git-id add --github # work
git-id add --github # personal
git-id add --github # clientUse different profiles for different repos
git clone git@github.com:company/repo.git --profile work
git clone git@github.com:username/project.git --profile personal
git clone git@github.com:client/app.git --profile clientEach repo automatically uses the correct identity and SSH key
`---
Project Structure
`
git-id-cli/
├── src/
│ ├── index.ts # Main CLI entry point
│ ├── profile-manager.ts # Profile CRUD operations
│ ├── github-auth.ts # GitHub OAuth flow
│ ├── ssh-manager.ts # SSH key generation & upload
│ ├── git-config.ts # Git configuration management
│ ├── git-wrapper.ts # Git command wrapper for --profile
│ ├── prompts.ts # CLI prompts
│ └── types.ts # TypeScript types
├── scripts/
│ └── postinstall.js # Automatic shell configuration
├── dist/ # Compiled JavaScript (generated)
├── package.json
├── tsconfig.json
└── README.md # This file
`---
How It Works
$3
Profiles are stored in
~/.git-id/profiles.json:`json
{
"work": {
"name": "John Doe",
"email": "john@company.com",
"github": "john-work",
"sshKey": "~/.ssh/id_ed25519_work",
"signingKey": null
}
}
`$3
- Key Generation: ED25519 keys are generated per profile
- Key Location:
~/.ssh/id_ed25519_
- SSH Config: Auto-configured in ~/.ssh/config with host aliases
- GitHub Upload: Public keys uploaded via OAuth during profile creation$3
When you use a profile, these Git configs are set:
`bash
git config --local user.name "John Doe"
git config --local user.email "john@company.com"
git config --local core.sshCommand "ssh -i ~/.ssh/id_ed25519_work"
`$3
The postinstall script adds this function to your shell:
`bash
git() {
if [[ " $ " == " --profile "* ]]; then
gitp "$@"
else
command git "$@"
fi
}
`This intercepts
git --profile commands and routes them through the CLI tool.---
File Locations
| What | Location |
|------|----------|
| Profiles |
~/.git-id/profiles.json |
| SSH Keys | ~/.ssh/id_ed25519_ |
| SSH Config | ~/.ssh/config |
| Shell Config | ~/.bashrc or ~/.zshrc |---
Development Commands
`bash
Install dependencies
npm installBuild TypeScript
npm run buildRun in dev mode (with ts-node)
npm run devLink globally for testing
npm linkUnlink
npm unlink -gTest the build
npm pack # Creates tarball to inspectPublish to npm (with build)
npm publish
`---
Troubleshooting Development Issues
$3
`bash
Clean and rebuild
rm -rf dist/
npm run build
`$3
`bash
Link the package
npm linkTest commands
git-id --version
git-id list
git-id add --githubUnlink when done
npm unlink -g
`$3
`bash
Check if linked
which git-id
which gitpReload shell config
source ~/.bashrcTest function
type git # Should show "git is a function"
``---
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test thoroughly
5. Submit a pull request
---
MIT