1

I have a project named mall

I have two remotes and two accounts.

I want to use git push to push to these two remotes with a different account, Like this:

user.email='a@g.com' push to git@github.com:a/mall.git

user.email='b@g.com' push to git@github.com:b/mall.git

Lin Du
  • 88,126
  • 95
  • 281
  • 483
  • This should be helpful: http://stackoverflow.com/questions/5343068/is-there-a-way-to-skip-password-typing-when-using-https-on-github – Tim Biegeleisen Apr 25 '17 at 06:08
  • `user.email` only affects your commits. Are you sure this is what you are asking? – xuhdev Apr 25 '17 at 08:24
  • @xuhdev yes. because I have two accounts , and I want the github to calculate the contributors for two accounts. You know , the contributors need the correct `user.email` – Lin Du Apr 25 '17 at 08:47
  • @novaline In this case, the two repos are not synchronized. Are you sure you wanna do this? – xuhdev Apr 25 '17 at 17:59

1 Answers1

0

The email is set at the commit, not at the push. A different email means a different sha, which means you'd better have 2 different repos: A and B.

Here is what you can do:

Code, commit and push in repo A. Create a script to do the following :

  • copy paste your project
  • execute git filter-branch to replace a@g.com into b@g.com
  • push to B

Everytime you push on A, run the script, or automate it using a hook.

Boris K
  • 1,469
  • 9
  • 29
  • Please do not suggest using `filter-branch` without explaining the consequences of doing so. OP’s workflow already appears to be broken based on their requirement but using `filter-branch` will only make it worse. – poke Apr 25 '17 at 09:05