0

I have two account in gitlab,
I want these accounts join on a project in gitlab as separate in my PC (as two ssh-key which added in gitlab profiles)
How do I switch between these account in my PC without any conflict or some things like this?

Benyamin Jafari
  • 15,536
  • 14
  • 81
  • 116
  • Possible duplicate of [How do I generate new ssh-key for my new gitlab account?](https://stackoverflow.com/questions/48248144/how-do-i-generate-new-ssh-key-for-my-new-gitlab-account) – phd Jan 14 '18 at 14:24
  • 1
    @phd In this question I hope to know how can I switch between these own accounts on a project in gitlab (single gitlab project, not two gitlab)! – Benyamin Jafari Jan 14 '18 at 14:27
  • But the answer is the same. You configure ssh. There is no magic that would switch keys for you. – phd Jan 14 '18 at 14:54
  • So, you have 2 ssh keys and added 1 of them to each profile, right? – Gonzalo Matheu Jan 14 '18 at 14:57

1 Answers1

1

If you are in a Linux terminal, you can create an ssh-agent session, then add, using ssh-add only the key of the account you want to use. For instance, if you want to use account 1:

eval `ssh-agent` # creates new ssh-agent session
ssh-add ~/.ssh/account1_rsa # add identity for account 1

ssh-agent session is valid for your terminal session, so you can open a second terminal and do the same for account 2.

I'm almost sure you can do the same in Windows using git's terminal.

Here a longer tutorial using ssh-agent and ssh-add.

Gonzalo Matheu
  • 6,511
  • 4
  • 29
  • 49