Git Profile allows you to switch between multiple user profiles in git repositories
If you are a macOS user, you can use Homebrew:
brew install dotzero/tap/git-profileDownload the binary from the releases page and place it under $PATH directory.
If your operating system does not have a binary release, but does run Go, you can build it from the source.
go get -u github.com/dotzero/git-profileThe binary will then be installed to $GOPATH/bin (or your $GOBIN).
Adds an entry to a profile or updates an existing profile
git profile add home user.name dotzero
git profile add home user.email "mail@mail.com"
git profile add home user.signingkey AAAAAAAAIf no arguments are provided, add starts an interactive mode:
git profile addIt will ask for the profile name and values for user.name, user.email, and
user.signingkey. Leaving a field empty skips writing that field for a new
profile. For an existing profile, the current values are prefilled and pressing
Enter keeps them unchanged. Press Esc or Ctrl+C to cancel interactive mode.
Displays a list of available profiles
git profile listDelete a profile or a specific key from a profile
git profile del
git profile del home
git profile del home user.emailWhen called without arguments, del opens an interactive profile selector and
removes the selected profile entirely.
Applies the selected profile entries to the current git repository
git profile use home
# Under the hood it runs following commands:
# git config --local user.name dotzero
# git config --local user.email "me@dotzero.ru"
# git config --local user.signingkey AAAAAAAAIf no profile name is provided, an interactive selector will appear to choose a profile
git profile useExport a profile in JSON format
git profile export home > home.jsonImport profile from JSON format
cat home.json | xargs -0 git profile import homeShell completion is available for git-profile command.
Note: Use git-profile TAB instead of git profile TAB for completion.
Requires bash-completion.
# Temporary (current session only)
source <(git-profile completion bash)
# Permanent (Linux)
git-profile completion bash | sudo tee /etc/bash_completion.d/git-profile
# Permanent (macOS)
git-profile completion bash > $(brew --prefix)/etc/bash_completion.d/git-profile# Create completion directory if it doesn't exist
mkdir -p ~/.zsh/completions
# Generate completion file
git-profile completion zsh > ~/.zsh/completions/_git-profile
# Add to ~/.zshrc if not already present
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
echo "autoload -U compinit && compinit" >> ~/.zshrc
# Reload shell
source ~/.zshrc# Temporary (current session only)
git-profile completion fish | source
# Permanent
git-profile completion fish > ~/.config/fish/completions/git-profile.fish