Cross-platform CLI tool to manage multiple Git profiles with SSH keys and shell aliases
npm install git-profile-setup``bash
$ git-profile-setup add
ā Initialized
ā¹ Configuring Git profile for John Doe...
ā SSH key generated & config updated!
š Your public SSH key:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK... john@personal.com
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⨠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:
git@github.com-john-doe: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 terminal
`
`bash
$ git-profile-setup add \
--name "Jane Smith" \
--email "jane@work.com" \
--type work
ā Initialized
ā¹ Configuring Git profile for Jane Smith...
ā SSH key generated & config updated!
š Your public SSH key:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK... jane@work.com
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⨠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:
git@github.com-jane-smith: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 terminal
`
`bash
$ git-profile-setup add --skip
ā Initialized
? Enter name āŗ John Doe
? Enter email āŗ john@example.com
? Select profile type āŗ personal
ā¹ Configuring Git profile for John Doe...
ā SSH key generated & config updated!
š Your public SSH key:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK... john@example.com
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⨠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:
git@github.com-john-doe:username/repo.git
ā Git profile configured globally
ā Profile John Doe configured!
š” Tip: Run without --skip flag to create shell aliases
`
`bash
$ git-profile-setup add
? Enter name āŗ John Doe
? Enter email āŗ john.doe@gmail.com
? Select profile type āŗ personal
ā Profile configured successfully!
⨠Alias created: git-john-doe
`
`bash
$ git-profile-setup add
? Enter name āŗ John Doe
? Enter email āŗ jdoe@company.com
? Select profile type āŗ work
ā Profile configured successfully!
⨠Alias created: git-john-doe-work
`
`bashSwitch to personal profile
$ git-john-doe
$3
`bash
Clone personal project
$ git clone git@github.com-john-doe:username/personal-project.gitClone work project
$ git clone git@github.com-john-doe-work:company/work-project.gitOr update existing remote
$ cd existing-repo
$ git remote set-url origin git@github.com-john-doe:username/repo.git
`Shell-Specific Alias Behavior
$3
`bash
Alias added to ~/.bashrc or ~/.zshrc
alias git-john-doe='git config user.name "John Doe" && git config user.email "john@example.com"'Usage
$ git-john-doe
$ git config user.name
John Doe
`$3
`fish
Alias added to ~/.config/fish/config.fish
alias git-john-doe 'git config user.name "John Doe"; and git config user.email "john@example.com"'Usage
$ git-john-doe
$ git config user.name
John Doe
`$3
`powershell
Function added to Microsoft.PowerShell_profile.ps1
function git-john-doe { git config user.name "John Doe"; git config user.email "john@example.com" }Usage
PS> git-john-doe
PS> git config user.name
John Doe
`Error Handling
$3
`bash
$ 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 aliases
`$3
`bash
$ git-profile-setup addā Initialized
ā¹ Configuring Git profile for John Doe...
ā Failed SSH key setup
ssh-keygen command not found
ā Failed to configure Git profile
`$3
`bash
$ 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 "john@example.com"
`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}.pubFor example:
- Personal profile:
~/.ssh/id_ed25519_personal.pub
- Work profile: ~/.ssh/id_ed25519_work.pub$3
1. Copy your public key:
`bash
cat ~/.ssh/id_ed25519_personal.pub
`2. Go to GitHub Settings ā SSH and GPG keys: https://github.com/settings/ssh/new
3. Click "New SSH key"
4. Add a descriptive title (e.g., "Personal Laptop - John Doe")
5. Paste your public key into the "Key" field
6. Click "Add SSH key"
$3
1. Copy your public key:
`bash
cat ~/.ssh/id_ed25519_personal.pub
`2. Go to GitLab Settings ā SSH Keys: https://gitlab.com/-/profile/keys
3. Paste your public key into the "Key" field
4. Add a descriptive title
5. Click "Add key"
$3
1. Copy your public key:
`bash
cat ~/.ssh/id_ed25519_personal.pub
`2. Go to Bitbucket Settings ā Personal settings ā SSH keys: https://bitbucket.org/account/settings/ssh-keys/
3. Click "Add key"
4. Paste your public key and add a label
5. Click "Add key"
$3
1. Copy your public key:
`bash
cat ~/.ssh/id_ed25519_personal.pub
`2. Go to Azure DevOps ā User Settings ā SSH Public Keys: https://dev.azure.com/{organization}/_usersSettings/keys
3. Click "New Key"
4. Paste your public key and add a description
5. Click "Add"
$3
Most Git hosting services follow a similar pattern:
1. Navigate to your account settings
2. Find the SSH keys section
3. Add a new SSH key
4. Paste the contents of your
.pub file
5. Save the keyImportant: 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
$3
`bash
$ git-profile-setup add
? Enter name āŗ John Doe
? Enter email āŗ john@freelance.com
? Select profile type āŗ custom
? Enter custom profile type āŗ freelanceCreates alias: git-john-doe
SSH key: ~/.ssh/id_ed25519_freelance
SSH key public: ~/.ssh/id_ed25519_freelance.pub
SSH host: github.com-john-doe
`$3
Running the command again with the same name updates the existing aliases:
`bash
$ git-profile-setup add --name "John Doe" --email "newemail@example.com" --type personal... setup ...
ā Updated alias in Bash (/home/user/.bashrc)
ā Profile configured successfully!
`$3
`bash
$ git config user.name
John Doe$ git config user.email
john@example.com
`$3
`bash
$ 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.pub
`Note: 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.$3
`bash
$ cat ~/.ssh/configgit-profile: John Doe
Host github.com-john-doe
HostName github.com
User git
IdentityFile /home/user/.ssh/id_ed25519_personal
IdentitiesOnly yesgit-profile: John Doe
Host github.com-john-doe-work
HostName github.com
User git
IdentityFile /home/user/.ssh/id_ed25519_work
IdentitiesOnly yes
``