includeIf for creating different git identities
With the following configuration git files. when you are at any subdirectory under ~/dev/work/
, the default git email account will be amy.lee123@arandomcompany.com, any other git directory will default to amy.lee123@gmail.com.
The git version has to be greater than 2.13, to check the current git version.
git version
To upgrade git using homebrew
brew upgrade git
.gitconfig, the git config file at the home directory, update it with the following.
[include] path = .gituser-default [includeIf "gitdir:~/dev/work/"] path = .gituser-work
.gituser-default, git user config for personal account, create this file at the home directory with the following, replace with your own name and email.
[user] name = Amy Lee email = amy.lee123@gmail.com
.gituser-work, the git user config for work account, create this file at the home directory with the following, replace with your own name and
[user] name = Amy Lee email = amy.lee123@arandomcompany.com
In order for the above configuration to work, the directory has to be initialized with git. The last command in the following commands should show the email address amy.lee123@arandomcompany.com
cd ~/dev/work/ mkdir test cd test git init touch README.txt git config user.email
Search within Codexpedia
Search the entire web