If you're a developer juggling between work projects, personal side projects, and maybe even some open-source contributions, you're likely familiar with a common frustrationβmanaging multiple Git identities on the same machine.
Imagine this scenario: You commit changes to your personal project and push them to GitHub, only to realize that your work email is attached to the commit. Or worse, you accidentally push a work-related change using your personal GitHub account. Fixing this means manually updating your Git config each time you switch contexts.
For years, developers have resorted to running:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
But this is tedious and error-prone. What if there was a better way?
Meet gguser
gguser
is a simple yet powerful CLI tool designed to seamlessly switch between multiple Git user profiles. Whether you're switching between work, personal, or open-source accounts, gguser
makes the process effortless.
π Installing gguser
Installing gguser
is quick and easy. Simply run:
npm install -g gguser
Now, you have gguser
available globally, ready to manage your Git profiles.
π― How to Use gguser
1οΈβ£ Adding Git Profiles
Before switching between Git users, you need to define them:
gguser add <profile_name> "<full_name>" "<email>" [ssh_key]
Example:
gguser add work "Shubhendra Chauhan" "work@company.com" ~/.ssh/id_ed25520
gguser add personal "Shubhendra Singh Chauhan" "personal@email.com" ~/.ssh/id_ed25521
Here, the SSH key is optional but useful if you want to authenticate using SSH.
2οΈβ£ Switching Between Git Profiles
Interactive Selection
Instead of remembering profile names, use:
gguser select
You'll see a list of your configured profiles and can simply pick one.
Quick Switching
If you already know which profile you want to switch to, just run:
gguser <profile_name>
Example:
gguser work
This updates your Git global config instantly.
3οΈβ£ Checking Your Current Git User
Ever wondered which Git identity is active? Quickly verify using:
gguser now
This command will display the currently configured Git user:
π€ Current Git User: Shubhendra Singh Chauhan <personal@email.com>
4οΈβ£ Managing Your Profiles
Listing All Profiles
To see all configured profiles, run:
gguser list
Removing a Profile
No longer need a profile? Remove it:
gguser remove <profile_name>
π Linking a Profile to a Directory
Many developers work on different projects that require different Git identities. For example:
- Your personal projects live in
~/projects/personal
- Your work projects live in
~/projects/work
Instead of manually switching Git users each time, you can link a profile to a specific directory:
gguser link work
Now, whenever you enter that directory, gguser
will automatically use the correct Git profile.
To unlink:
gguser unlink
π₯ Why gguser
is a Game-Changer
β
No more accidental commits with the wrong Git identity
β
Seamlessly switch between work, personal, and open-source profiles
β
Automatic profile selection based on directories
β
Easily manage SSH keys
β
Developer-friendly CLI with an interactive selection mode
π‘ Contribute or Extend gguser
gguser
is open-source, and contributions are welcome! If you have ideas for improvements or new features, feel free to submit a pull request. You can check out the repo here:
π GitHub: https://github.com/withshubh/gguser
π¦ NPM: https://www.npmjs.com/package/gguser
π― Final Thoughts
For developers working with multiple Git accounts, gguser
is a must-have tool. No more wasting time manually updating Git config settings or dealing with incorrect commit histories. Try it out today and simplify your workflow!
Let me know in the comments how gguser
has helped you! π
Top comments (0)