Bash script for switching the Git user easily.
Copy git-user into any directory and make sure it is in the PATH (and the executable flag is set).
git user add [email protected] "John DOE"
git user add [email protected] "John Doe"
# inside the Git repository
git user set [email protected]
# sets user.name to John DOE
# and user.email to [email protected]If gum or fzf is installed, then the user can be selected interactively by using the cursor keys:
git user set
# displays the following prompt
Select user (current: John DOE <[email protected]>):
John Doe <[email protected]>
> John DOE <[email protected]>
Users are stored in the global Git configuration. Hence, no additional config file is required.
git config --get-regexp 'users\..*'
# prints
[email protected] John DOE
[email protected] [email protected]
[email protected] John Doe
[email protected] [email protected]By default, the global Git configuration is stored in ${HOME}/.gitconfig e.g.,
[core]
autocrlf = false
...
[users "[email protected]"]
name = John DOE
email = [email protected]
[users "[email protected]"]
name = John Doe
email = [email protected]Incomplete list of similar tools (ordered by stars in descending order, as of January 2023):
- https://github.com/geongeorge/Git-User-Switch
- https://github.com/matsuyoshi30/gitsu
- https://github.com/joealba/gitswitch
- https://github.com/gesquive/git-user
- https://github.com/forthedamn/gitum
- https://github.com/WindomZ/gituser.js
- https://github.com/krnsk0/guser
- https://github.com/spenserblack/change-git-user
- https://github.com/WindomZ/gituser
- https://github.com/timo-cmd/glitter