cd ..

Change Your Git User Depending on the Current Working Directory with Conditional Includes

Git 2.13+ introduced Conditional Includes which allow to set the Git user name depending on the Git repo location (and much more).

The following example defaults my Git user to Kevin <> and switches to Vincent Adultman <> if the repo is located in ~/job.


  path = ~/.dotfiles/git/private.gituser
[includeIf "gitdir/i:~/job/"]
  path = ~/.dotfiles/git/job.gituser
# ...
# ~/.dotfiles/git/job.gituser

# ~/.dotfiles/git/private.gituser

  name="Vincent Adultman"

(First seen at