Skip to content

Bash script for switching the Git user easily

License

Notifications You must be signed in to change notification settings

abc-inc/git-user

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-user

Bash script for switching the Git user easily.

Installation

Copy git-user into any directory and make sure it is in the PATH (and the executable flag is set).

Usage

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]>

Implementation Details

Users are stored in the global Git configuration. Hence, no additional config file is required.

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]

Alternatives

Incomplete list of similar tools (ordered by stars in descending order, as of January 2023):

Releases

No releases published