Git Id Switch
Effortlessly switch between multiple Git identities in VS Code.
If you use the same machine for personal projects and work, you know the pain: committing with the wrong email, pushing with the wrong GitHub account, or constantly running git config commands. Git Id Switch solves this with one-click profile switching right from your status bar.
Features
Multiple Git Profiles
Create named profiles (e.g., "Personal", "Work") with separate:
- Git user.name and user.email
- GPG or SSH signing key for verified commits
- GitHub Personal Access Token for seamless
gh CLI auth
One-Click Switching
Click the status bar indicator or run the Switch Profile command to instantly change your Git identity. The extension updates:
git config user.name and user.email (local or global scope)
- Commit signing configuration (
user.signingkey, commit.gpgSign, gpg.format)
- GitHub CLI authentication via
gh auth login
Auto-Detection
When you open a repository, the extension reads the current git config and automatically matches it to one of your saved profiles — so the status bar always shows the right identity.
Secure Token Storage
GitHub tokens are stored using VS Code's SecretStorage API, which delegates to your operating system's keychain (macOS Keychain, Windows Credential Manager, or Linux libsecret). Tokens are never stored in plain text.
Getting Started
1. Install the Extension
Search for "Git Id Switch" in the VS Code Extensions Marketplace, or install from a .vsix file:
code --install-extension git-id-switch-0.1.0.vsix
2. Add Your First Profile
Open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P) and run:
Git Id Switch: Add Profile
You'll be guided through entering:
- A label (e.g., "Work")
- Your git name
- Your git email
- A signing key (optional)
- A GitHub Personal Access Token (optional)
3. Switch Profiles
Click the person icon in the status bar, or run:
Git Id Switch: Switch Profile
Select a profile and you're done. Your git config and GitHub CLI auth are updated instantly.
Commands
| Command |
Description |
Git Id Switch: Add Profile |
Create a new identity profile |
Git Id Switch: Edit Profile |
Modify an existing profile |
Git Id Switch: Delete Profile |
Remove a profile and its stored token |
Git Id Switch: Switch Profile |
Switch to a different identity |
Git Id Switch: Show Current Profile |
View active profile and actual git config |
Settings
| Setting |
Default |
Description |
git-id-switch.scope |
local |
Apply identity per-repo (local) or system-wide (global) |
git-id-switch.configureGhCli |
true |
Automatically run gh auth login when switching profiles |
git-id-switch.statusBarAlignment |
left |
Position the status bar indicator on the left or right |
How It Works
+------------------+ +-----------------+ +------------------+
| Profile Store | ----> | Git Config | ----> | git user.name |
| (globalState) | | Writer | | git user.email |
| | | (execFile) | | user.signingkey |
+------------------+ +-----------------+ +------------------+
|
v
+------------------+ +-----------------+
| SecretStorage | ----> | GitHub CLI |
| (OS Keychain) | | Auth Manager |
| [PAT tokens] | | (gh auth login) |
+------------------+ +-----------------+
- Profile metadata (name, email, label, signing key) is stored in VS Code's
globalState — synced across instances if Settings Sync is enabled.
- GitHub tokens are stored in
SecretStorage backed by your OS keychain — never written to disk as plain text.
- Git config is modified via
git config CLI calls using child_process.execFile (no shell, no injection risk).
- GitHub CLI auth is set via
gh auth login --with-token for persistent system-wide access.
Requirements
- VS Code 1.85.0 or later
- Git installed and available on your PATH
- GitHub CLI (
gh) — optional, required only for automatic GitHub auth switching
Security
- Tokens are stored in your OS keychain via VS Code SecretStorage, not in settings files or plain text.
- Git config values are passed as process arguments via
execFile (not shell-interpolated), preventing command injection.
- The extension runs only in trusted workspaces.
Generating a GitHub Personal Access Token
- Go to GitHub Settings > Developer settings > Personal access tokens > Fine-grained tokens
- Click Generate new token
- Give it a descriptive name (e.g., "Git Id Switch - Work")
- Select the repositories and permissions you need
- Copy the generated token and paste it when adding/editing a profile in the extension
Repeat for each GitHub account you want to configure.
FAQ
Q: Does switching profiles affect other terminal sessions?
A: For git config with local scope, it only affects the current repository. With global scope, it applies system-wide. GitHub CLI auth (gh auth login) is always system-wide.
Q: What happens if I don't have gh installed?
A: The extension works fine without it — git identity switching works independently. GitHub CLI auth configuration is silently skipped.
Q: Can I use this with GitHub Enterprise?
A: Yes. When adding a profile, the ghHost field lets you specify a custom GitHub hostname. This defaults to github.com.
Q: Are my tokens safe?
A: Yes. Tokens are stored using VS Code's SecretStorage API, which delegates to your operating system's native credential store (macOS Keychain, Windows Credential Manager, Linux libsecret).
Contributing
- Clone the repository
- Run
npm install
- Open in VS Code and press
F5 to launch the Extension Development Host
- Make your changes and test them in the development window
License
MIT