git identity manager
zit chooses a git identity based on:
- git remote host
- repository owner
- repository name
… as defined in the configuration file:
{{.ExampleYaml}}
There are 2 ways to set up a configuration file:
- Place it at the default location:
$HOME/.zit/config.yaml
- Specify an environment variable that points to the config file:
export ZIT_CONFIG=/custom-location/.zit-config.yaml
If the environment variable is set up, it will be chosen over the config at the default location.
To set up an identity, run zit set
inside a repo directory:
$ zit set # personal repo
set user: jdoe <[email protected]>
$ git remote get-url origin
https://github.com/jdoe/repo.git
$ zit set # work repo
set user: John Doe <[email protected]>
$ git remote get-url origin
[email protected]:team/repo.git
Note: Use --dry-run
flag to test which identity will be used without
applying it.
On Mac/Linux with Homebrew
brew tap ayakovlenko/tools
brew install ayakovlenko/tools/zit
From sources
git clone https://github.com/ayakovlenko/zit.git
cd zit
go install
From binaries
Download binaries from the releases page.
Remove any existing global identity
git config --unset-all --global user.name
git config --unset-all --global user.email
git config --unset-all --system user.name
git config --unset-all --system user.email
Require config to exist in order to make commits
git config --global user.useConfigOnly true
Without the global user name and user email, git would use the system's hostname and username to make commits. Tell git to throw an error instead, requiring you to specify an identity for every new project.
Run zit doctor
to make sure the system is configured correctly:
$ zit doctor
- [x] git config --global user.useConfigOnly true
- [x] git config --unset-all --global user.name
- [x] git config --unset-all --global user.email
- [x] git config --unset-all --system user.name
- [x] git config --unset-all --system user.email