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 <k@example.com> and switches to Vincent Adultman <va@example.com> if the repo is located in ~/job.

#~/.gitconfig

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

[user]
  name="Kevin"
  email="k@example.com"
# ~/.dotfiles/git/private.gituser

[user]
  name="Vincent Adultman"
  email="va@example.com"

(First seen at https://motowilliams.com/2017-05-11-conditional-includes-for-git-config/)