Skip to content

Instantly share code, notes, and snippets.

@oclero
Created November 8, 2021 10:03
Show Gist options
  • Save oclero/7dc037a4892e46b7ccc9ed60b5101549 to your computer and use it in GitHub Desktop.
Save oclero/7dc037a4892e46b7ccc9ed60b5101549 to your computer and use it in GitHub Desktop.
How to setup a different Git user for a directory

If you want to make Git commits with a specific name and email for all repositories placed inside a directory, i.g. a /personal directory on your company's computer, here is how to do.

  1. In the personal directory, create a .gitconfig file.

    [user]
      name = Your Name
      email = your.email@mail.com
  2. In your $home, edit the .gitconfig file to add these lines:

    [includeIf "gitdir:path/to/personal/"]
      path = path/to/personal/.gitconfig   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment