Git Profile helps you manage multiple Git identities and switch between them per repository.
brew install dotzero/tap/git-profileDownload a binary from the releases page and place it in a directory listed in $PATH.
go install github.com/dotzero/git-profile@latestThe binary will be installed to $GOBIN or $GOPATH/bin.
Create a profile in interactive mode:
git-profile addApply a profile in the current Git repository:
git-profile useAdd a key to a profile or update an existing one:
git-profile add work user.name "John Doe"
git-profile add work user.email work@example.com
git-profile add work user.signingkey AAAAAAAARun without arguments to start interactive mode:
git-profile addInteractive mode asks for:
- profile name
user.nameuser.emailuser.signingkey
For an existing profile, current values are prefilled. For a new profile, empty fields are skipped.
Show all available profiles:
git-profile listDelete a profile or a specific key from a profile:
git-profile del
git-profile del work
git-profile del work user.emailWhen called without arguments, del opens an interactive profile selector and deletes the selected profile.
Press Esc or Ctrl+C to cancel.
Apply a profile to the current Git repository:
git-profile use workUnder the hood, this writes local Git config values, for example:
git config --local user.name "John Doe"
git config --local user.email work@example.com
git config --local user.signingkey AAAAAAAARun without arguments to select a profile interactively:
git-profile useuse must be executed inside a Git repository.
Show the currently selected profile for the current repository:
git-profile currentExport a profile as JSON:
git-profile export work
git-profile export work > work.jsonExample output:
[
{ "key": "user.name", "value": "John Doe" },
{ "key": "user.email", "value": "work@example.com" },
{ "key": "user.signingkey", "value": "AAAAAAAA" }
]Import a profile from JSON:
git-profile import work '[{"key":"user.name","value":"John Doe"},{"key":"user.email","value":"work@example.com"}]'If you already have JSON in a file:
git-profile import work "$(cat work.json)"By default, Git Profile stores profiles in:
~/.gitprofileYou can override it with:
git-profile --config /path/to/file add work user.email work@example.comShell completion is available for git-profile.
Note: use git-profile ..., not git profile ..., when generating or using completion.
Requires bash-completion.
source <(git-profile completion bash)To install permanently:
git-profile completion bash | sudo tee /etc/bash_completion.d/git-profileOn macOS:
git-profile completion bash > $(brew --prefix)/etc/bash_completion.d/git-profilemkdir -p ~/.zsh/completions
git-profile completion zsh > ~/.zsh/completions/_git-profile
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
echo 'autoload -U compinit && compinit' >> ~/.zshrc
source ~/.zshrcgit-profile completion fish | source
git-profile completion fish > ~/.config/fish/completions/git-profile.fish