Skip to content

Instantly share code, notes, and snippets.

@m99coder
Forked from asaaki/.gitconfig
Created February 2, 2021 11:10
Show Gist options
  • Save m99coder/05624af85b72fa374767986bd5fdb564 to your computer and use it in GitHub Desktop.
Save m99coder/05624af85b72fa374767986bd5fdb564 to your computer and use it in GitHub Desktop.
Using different emails and GPG keys for work and personal stuff on GitHub
[core]
# ...
[init]
defaultBranch = main
[commit]
gpgsign = true
# you want that to have a default for locations outside of your regular dev folders
[include]
path = ~/.gitconfig.personal
# IMPORTANT: Yes, the trailing slash is required!
[includeIf "gitdir:~/Development/Personal/"]
path = ~/.gitconfig.personal
[includeIf "gitdir:~/Development/Work/"]
path = ~/.gitconfig.work
[user]
name = <YOUR NAME>
email = <YOUR MAIN/PERSONAL EMAIL>
signingkey = <YOUR GPG KEY FOR PERSONAL EMAIL>
[user]
name = <YOUR NAME>
email = <YOUR WORK EMAIL>
signingkey = <YOUR GPG KEY FOR WORK EMAIL>
# ~/.ssh/config
Host github.com
Hostname github.com
User <YOUR GITHUB USERNAME>
IdentityFile <PATH TO YOUR MAIN KEY>
IdentitiesOnly yes
# if you use the multi-key approach, see NOTES.md
Host github.com-work
Hostname github.com
User <YOUR GITHUB USERNAME>
IdentityFile <PATH TO YOUR WORK KEY>
IdentitiesOnly yes
Host *
PreferredAuthentications publickey
Compression yes
ServerAliveInterval 30
ServerAliveCountMax 9999
VisualHostKey yes
AddKeysToAgent yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment