Skip to content

vinugawade/gitswap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitSwap - Manage Git Users Easily 🔄

Linux MacOS Bash

GitHub issues GitHub code size in bytes GitHub last commit

If you work with multiple Git users and need an easy way to switch between them, gitswap is the script for you. It allows you to list, add, remove, and switch Git users quickly on Linux, MacOS, and Windows.


Installation 🚀

  1. Clone the Repository:

    • Clone the gitswap repository to your local machine using the following command:
    git clone https://github.com/vinugawade/gitswap.git
  2. Move the Script to a Global Location:

    • Move the script to a global location on your system using the following command:
    sudo mv /location/of/gitswap /usr/local/bin
  3. Set Script Permissions:

    • Allow everyone to execute the script by choosing one of the following commands:
    sudo chmod +x /location/of/gitswap

    OR

    sudo chmod 0755 /location/of/gitswap
  4. Add to $PATH:

    • Add /usr/local/bin to your $PATH. If you use the Bash shell, execute the command:
    export PATH=$PATH:/usr/local/bin

    OR

    export PATH=$PATH:/location/of/gitswap

    This will set the variable name, potentially in a file like ~/.bash_profile, ~/.bashrc, or ~/.profile. If you're unsure where to put it, ~/.bashrc is a good choice.

You may need to restart your shell for this to take effect.


Script Options 🎛️

The gitswap script supports the following options:

  • --switch, -s: Switch to a new or existing Git user.
  • --add, -a: Add a new Git user to the list.
  • --remove, -r: Remove a Git user from the list.
  • --show, -sh: Display the current Git user configuration.

Usage 🛠️

  • Switch User: Switch to an existing Git user or add a new one if the user doesn't exist.

    gitswap "John Doe" "john.doe@example.com"
  • Add User: Add a new Git user to the saved list.

    gitswap --add  # Prompts to add a new Git user to the list
    gitswap "Jane Doe" "jane.doe@example.com"  # Adds a new user if provided
  • Remove User: Remove a Git user from the saved list.

    gitswap --remove  # Prompts to choose a user to remove
  • Show Current User: Display the current Git user configuration.

    gitswap --show  # Displays the current Git user configuration
  • List Users: If no arguments or options are provided, gitswap will list all saved Git users.

    gitswap  # Lists all saved Git users

Features 🌟

  • Switch Users: Easily switch between multiple Git users.
  • Add Users: Add new Git users to the saved list.
  • Remove Users: Remove users from the saved list.
  • Show Current User: Quickly view the currently active Git user.
  • Auto-Add: If no users are saved, the current Git user is automatically added to the list.

Maintainer 👨🏻‍💻

Vinay Gawade's Dev Card

Built With 💙✨ By Vinay Gawade.

LinkedIn Logo Buy Me a Coffee Logo Twitter Logo

License 🛂

LICENSE

This project is licensed under the LICENSE file associated with this repository.

About

A lightweight CLI tool to easily manage and switch between multiple Git user profiles. Perfect for developers working on projects with different Git account.

Topics

Resources

License

Stars

2 stars

Watchers

1 watching

Forks

Contributors

Languages