Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify multiple user.name and user.email for different git remotes?

Tags:

git

I have a repository in my local machine. This repository has 2 git remotes. Remotes A and B.

  • Remote A requires user.name X and user.email Y.
  • Remote B requires user.name Z and user.email W.

Can this be achieved in git? If so, how?

like image 910
Abel Callejo Avatar asked Jul 14 '17 00:07

Abel Callejo


1 Answers

With Git 2.13, you now have conditional include for git config, but it is only based on filesystem path of the repository.

So you still need two different copies of the same repo. You can achieve that with git worktree (one clone, multiple working tree)

You can then modify your global config spec to include a local config with a specific set of user.name/user.email depending on your current folder.
See "Using different Git emails" from pltvs (Alex Pliutau)

like image 144
VonC Avatar answered Sep 28 '22 06:09

VonC