Skip to content

Instantly share code, notes, and snippets.

@vuldin
Last active April 29, 2022 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vuldin/5c078744e6e7bba658842117d0b7e5ad to your computer and use it in GitHub Desktop.
Save vuldin/5c078744e6e7bba658842117d0b7e5ad to your computer and use it in GitHub Desktop.
How to commit to different repos using a different name/email

These instructions assume you have a personal and work email. The default email will be personal, and all repos in a folder ~/work will be commited to with your work email. Change ~/work in the details below to whatever you want (ie. your company's name).

Create ~/.gitconfig with the following contents:

[user]
name = <your name>
email = <personal email>
[includeIf "gitdir:~/work/"]
  path = ~/work/.gitconfig_include

Create and move into the work folder:

mkdir work && cd work

Create ~/work/.gitconfig_include with the following contents:

[user]
email = <work email>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment