Skip to main content

Adapting Your Git Config for Work

  • Change your git config on your work laptop
  • If you use a common gitconfig on multiple laptops, you can use the includeIf directive to change your git config on your work laptop
  • Settings you may want to change include:
    • user.name
    • user.email
    • defaultBranch
  • In my case, I like to use my personal email address and main as the default branch on my personal laptop, but my work email address and trunk as the default branch on my work laptop
  • To do this, I have the following in my ~/.gitconfig:
    [includeIf "gitdir:~/work/"]
      path = ~/.gitconfig-work
    
  • And the following in my ~/.gitconfig-work:
    [user]
      email = "YOUR EMAIL"
    [init]
      defaultBranch = trunk
    
  • You can also use includeIf to change your git config based on the hostname of the machine you’re on
  • Need to add your work email address to your GitHub account? See this guide from GitHub

See /github-notifications-custom-routing/ if I want to also address how to route GitHub notifications to different email addresses

Inbox