GitMorph is a powerful CLI tool that allows you to seamlessly switch between multiple Git identities on your local machine. Perfect for developers who work on different projects with various Git accounts.
- Create and manage multiple Git profiles
- Easily switch between different Git identities
- List all available profiles
- Simple and intuitive command-line interface
To install GitMorph, make sure you have Go installed on your system, then run:
go install github.com/abhigyan-mohanta/gitmorph
After installation, you may need to add the Go binaries directory to your system's PATH
so you can run gitmorph
from anywhere. Here are the steps:
-
Check the directory where Go installs executables by running:
go env GOPATH
-
Open your
.zshrc
file for editing:nano ~/.zshrc
-
Add the following line to include the Go binaries directory in your
PATH
:export PATH=$PATH:$(go env GOPATH)/bin
-
Save the file and exit, then apply the changes:
source ~/.zshrc
GitMorph provides the following commands:
gitmorph new
This command will prompt you to enter a profile name, Git username, and Git email.
gitmorph switch <profile-name>
This command switches your global Git configuration to the specified profile.
gitmorph list
This command displays all available Git profiles.
GitMorph stores your Git profiles in a JSON file located at ~/.gitmorph.json
. When you switch profiles, it updates your global Git configuration using the git config --global
command.
The project is structured as follows:
main.go
: Entry point of the applicationcmd/root.go
: Defines the root command and common functionalitycmd/new.go
: Implements the "new" command to create profilescmd/switch.go
: Implements the "switch" command to change profilescmd/list.go
: Implements the "list" command to display profiles
For seamless Git operations with multiple accounts, you can set up SSH configurations. Below is an example of how your SSH config file (~/.ssh/config
) should look:
# Work GitHub Account
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
AddKeysToAgent yes
# Personal GitHub Account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
AddKeysToAgent yes
To create an SSH key for your personal account, you can use the following command:
ssh-keygen -t ed25519 -C "your_email@example.com" -f ~/.ssh/id_ed25519_personal
- When using the main
id_ed25519.pub
, the normal command for pushing changes works as expected:
git push -u origin main
- For other accounts, you need to specify the SSH command:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519_personal" git push -u origin main
- Alternatively, you can configure the SSH command to use your SSH config file:
GIT_SSH_COMMAND="ssh -F ~/.ssh/config" git push -u origin main
GitMorph uses the following external libraries:
require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
Contributions are welcome! Please feel free to submit a Pull Request.