git-profile-setup
v1.0.1
Published
Cross-platform CLI tool to manage multiple Git profiles with SSH keys and shell aliases
Maintainers
Readme
Usage Examples
Interactive Mode with Alias Creation
$ git-profile-setup add
✔ Initialized
ℹ Configuring Git profile for John Doe...
✔ SSH key generated & config updated!
📋 Your public SSH key:
──────────────────────────────────────────────────
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK... [email protected]
──────────────────────────────────────────────────
✨ Add this key to your cloud service account (GitHub, GitLab, Bitbucket, etc.)
See "Adding SSH Keys to Cloud Services" section below for detailed instructions
🔧 SSH Host alias created: github.com-john-doe
Use this in your git remote URL:
[email protected]:username/repo.git
✔ Git profile configured globally
🐚 Detected 3 shell(s):
• Bash → /home/user/.bashrc
• Zsh → /home/user/.zshrc
• Fish → /home/user/.config/fish/config.fish
? Would you like to create a shell alias to switch to this profile? › Yes
? Select shells to add the alias to: ›
↑/↓: Navigate • Space: Toggle • Enter: Confirm
◉ Bash → /home/user/.bashrc
◉ Zsh → /home/user/.zshrc
◯ Fish → /home/user/.config/fish/config.fish
📝 Adding aliases to selected shells...
✔ Added alias to Bash (/home/user/.bashrc)
✔ Added alias to Zsh (/home/user/.zshrc)
✔ Profile configured successfully!
✨ Alias created: git-john-doe
Run this command to switch to this profile:
$ git-john-doe
🔄 To use the alias immediately, reload your shell:
Bash/Git Bash: source ~/.bashrc (or restart terminal)
Zsh: source ~/.zshrc (or restart terminal)
Or simply restart your terminalCommand Line Mode
$ git-profile-setup add \
--name "Jane Smith" \
--email "[email protected]" \
--type work
✔ Initialized
ℹ Configuring Git profile for Jane Smith...
✔ SSH key generated & config updated!
📋 Your public SSH key:
──────────────────────────────────────────────────
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK... [email protected]
──────────────────────────────────────────────────
✨ Add this key to your cloud service account (GitHub, GitLab, Bitbucket, etc.)
See "Adding SSH Keys to Cloud Services" section below for detailed instructions
🔧 SSH Host alias created: github.com-jane-smith
Use this in your git remote URL:
[email protected]:username/repo.git
✔ Git profile configured globally
🐚 Detected 2 shell(s):
• PowerShell → C:\Users\jane\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
• Git Bash → C:\Users\jane\.bashrc
? Would you like to create a shell alias to switch to this profile? › Yes
? Select shells to add the alias to: ›
◉ PowerShell → C:\Users\jane\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
◉ Git Bash → C:\Users\jane\.bashrc
📝 Adding aliases to selected shells...
✔ Added alias to PowerShell (C:\Users\jane\Documents\PowerShell\Microsoft.PowerShell_profile.ps1)
✔ Added alias to Git Bash (C:\Users\jane\.bashrc)
✔ Profile configured successfully!
✨ Alias created: git-jane-smith
Run this command to switch to this profile:
$ git-jane-smith
🔄 To use the alias immediately, reload your shell:
PowerShell: . $PROFILE (or restart terminal)
Bash/Git Bash: source ~/.bashrc (or restart terminal)
Or simply restart your terminalSkip Alias Creation
$ git-profile-setup add --skip
✔ Initialized
? Enter name › John Doe
? Enter email › [email protected]
? Select profile type › personal
ℹ Configuring Git profile for John Doe...
✔ SSH key generated & config updated!
📋 Your public SSH key:
──────────────────────────────────────────────────
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK... [email protected]
──────────────────────────────────────────────────
✨ Add this key to your cloud service account (GitHub, GitLab, Bitbucket, etc.)
See "Adding SSH Keys to Cloud Services" section below for detailed instructions
🔧 SSH Host alias created: github.com-john-doe
Use this in your git remote URL:
[email protected]:username/repo.git
✔ Git profile configured globally
✔ Profile John Doe configured!
💡 Tip: Run without --skip flag to create shell aliasesMultiple Profile Workflow
1. Create Personal Profile
$ git-profile-setup add
? Enter name › John Doe
? Enter email › [email protected]
? Select profile type › personal
# ... setup process ...
✔ Profile configured successfully!
✨ Alias created: git-john-doe2. Create Work Profile
$ git-profile-setup add
? Enter name › John Doe
? Enter email › [email protected]
? Select profile type › work
# ... setup process ...
✔ Profile configured successfully!
✨ Alias created: git-john-doe-work3. Switch Between Profiles
# Switch to personal profile
$ git-john-doe
# Verify
$ git config user.name
John Doe
$ git config user.email
[email protected]
# Switch to work profile
$ git-john-doe-work
# Verify
$ git config user.name
John Doe
$ git config user.email
[email protected]4. Use Different SSH Keys
# Clone personal project
$ git clone [email protected]:username/personal-project.git
# Clone work project
$ git clone [email protected]:company/work-project.git
# Or update existing remote
$ cd existing-repo
$ git remote set-url origin [email protected]:username/repo.gitShell-Specific Alias Behavior
Bash/Zsh/Git Bash
# Alias added to ~/.bashrc or ~/.zshrc
alias git-john-doe='git config user.name "John Doe" && git config user.email "[email protected]"'
# Usage
$ git-john-doe
$ git config user.name
John DoeFish
# Alias added to ~/.config/fish/config.fish
alias git-john-doe 'git config user.name "John Doe"; and git config user.email "[email protected]"'
# Usage
$ git-john-doe
$ git config user.name
John DoePowerShell
# Function added to Microsoft.PowerShell_profile.ps1
function git-john-doe { git config user.name "John Doe"; git config user.email "[email protected]" }
# Usage
PS> git-john-doe
PS> git config user.name
John DoeError Handling
No Shells Detected
$ git-profile-setup add
✔ Initialized
✔ SSH key generated & config updated!
✔ Git profile configured globally
⚠ No supported shells detected. Skipping alias creation.
💡 Supported shells: Bash, Zsh, Fish, PowerShell, Git Bash
Install one of these shells to use shell aliasesSSH Key Generation Failed
$ git-profile-setup add
✔ Initialized
ℹ Configuring Git profile for John Doe...
✖ Failed SSH key setup
ssh-keygen command not found
✖ Failed to configure Git profileUser Cancels Selection
$ git-profile-setup add
✔ Initialized
✔ SSH key generated & config updated!
✔ Git profile configured globally
🐚 Detected 3 shell(s):
• Bash → /home/user/.bashrc
• Zsh → /home/user/.zshrc
• Fish → /home/user/.config/fish/config.fish
? Would you like to create a shell alias to switch to this profile? › No
✔ Profile John Doe configured!
💡 You can manually switch to this profile using:
git config user.name "John Doe"
git config user.email "[email protected]"Adding SSH Keys to Cloud Services
After generating your SSH key, you need to add the public key (.pub file) to your cloud service accounts. The public key file is located at:
Location: ~/.ssh/id_ed25519_{type}.pub
For example:
- Personal profile:
~/.ssh/id_ed25519_personal.pub - Work profile:
~/.ssh/id_ed25519_work.pub
GitHub
Copy your public key:
cat ~/.ssh/id_ed25519_personal.pubGo to GitHub Settings → SSH and GPG keys: https://github.com/settings/ssh/new
Click "New SSH key"
Add a descriptive title (e.g., "Personal Laptop - John Doe")
Paste your public key into the "Key" field
Click "Add SSH key"
GitLab
Copy your public key:
cat ~/.ssh/id_ed25519_personal.pubGo to GitLab Settings → SSH Keys: https://gitlab.com/-/profile/keys
Paste your public key into the "Key" field
Add a descriptive title
Click "Add key"
Bitbucket
Copy your public key:
cat ~/.ssh/id_ed25519_personal.pubGo to Bitbucket Settings → Personal settings → SSH keys: https://bitbucket.org/account/settings/ssh-keys/
Click "Add key"
Paste your public key and add a label
Click "Add key"
Azure DevOps
Copy your public key:
cat ~/.ssh/id_ed25519_personal.pubGo to Azure DevOps → User Settings → SSH Public Keys: https://dev.azure.com/{organization}/_usersSettings/keys
Click "New Key"
Paste your public key and add a description
Click "Add"
Other Services
Most Git hosting services follow a similar pattern:
- Navigate to your account settings
- Find the SSH keys section
- Add a new SSH key
- Paste the contents of your
.pubfile - Save the key
Important: Make sure to add the correct public key for each profile to the corresponding account. For example, add your work profile's public key to your work GitHub/GitLab account, and your personal profile's key to your personal account.
Advanced Usage
Custom Profile Type
$ git-profile-setup add
? Enter name › John Doe
? Enter email › [email protected]
? Select profile type › custom
? Enter custom profile type › freelance
# Creates alias: git-john-doe
# SSH key: ~/.ssh/id_ed25519_freelance
# SSH key public: ~/.ssh/id_ed25519_freelance.pub
# SSH host: github.com-john-doeUpdate Existing Profile
Running the command again with the same name updates the existing aliases:
$ git-profile-setup add --name "John Doe" --email "[email protected]" --type personal
# ... setup ...
✔ Updated alias in Bash (/home/user/.bashrc)
✔ Profile configured successfully!Check Current Profile
$ git config user.name
John Doe
$ git config user.email
[email protected]List All SSH Keys
$ ls ~/.ssh/id_ed25519*
/home/user/.ssh/id_ed25519_personal
/home/user/.ssh/id_ed25519_personal.pub
/home/user/.ssh/id_ed25519_work
/home/user/.ssh/id_ed25519_work.pubNote: The .pub files are the public keys you need to add to your cloud service accounts (GitHub, GitLab, Bitbucket, etc.). See the "Adding SSH Keys to Cloud Services" section above for instructions.
View SSH Config
$ cat ~/.ssh/config
# git-profile: John Doe
Host github.com-john-doe
HostName github.com
User git
IdentityFile /home/user/.ssh/id_ed25519_personal
IdentitiesOnly yes
# git-profile: John Doe
Host github.com-john-doe-work
HostName github.com
User git
IdentityFile /home/user/.ssh/id_ed25519_work
IdentitiesOnly yes