I'll-Be-Back
I'll-Be-Back

Reputation: 10838

Working with two different Github Accounts

I have a personal and Work Github Accounts.

By default, git user.email is set to my personal email address. (git config user.email)

Is there a way if I clone repos from Work github account - it will use work email address automatically? Or what is right approach?

Upvotes: 0

Views: 56

Answers (2)

Madi Naf
Madi Naf

Reputation: 665

I suggest you configure your git with git config user.name & git config user.emailwhenever you need it. Otherwise, if you can work with your two accounts on the same project, you can add your second account as a contributor.

Upvotes: 0

Geno Chen
Geno Chen

Reputation: 5214

There are several levels of ranges for git config,

  1. --global, writes to ~/.gitconfig
  2. --system, writes to ${prefix}/etc/gitconfig
  3. --local, default, writes to project .git/config
  4. --worktree, writes to project .git/config.wroktree, similar to --local

You can use the project wide --local config files to override the --global value, that is, when you setup a project with work account, immediately git config to add a project wide user.name and user.email.

Upvotes: 1

Related Questions