Multiple github accounts on the same computer?

后端 未结 25 2276
野的像风
野的像风 2020-11-22 02:56

Trying to work on my both my actual \"work\" repos, and my personal repos on git hub, from my computer.

The work account was set up first, and everything works flawl

25条回答
  •  花落未央
    2020-11-22 03:44

    • Go to ~/.ssh
    • Create a file named config(have no extension )
    • Open config file & add below codes. (change according to your account)

      1. Account 1

        # account_1
        Host gitlab.com-account_1
        HostName gitlab.com
        User git
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/id_rsa_account_1
        
      2. Account 2

        # Account2
        Host gitlab.com-Account2
        HostName gitlab.com
        User git
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/id_rsa_Account2
        
      3. Account 3

        # Account_3
        Host github.com-Account3
        HostName github.com
        User git
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/id_rsa_Account_3
        
    • Add remote url as follows

      1. Account 1

        git remote add origin git@gitlab.com-account_1:group_name/repo_name.git
        
      2. Account 2

        git remote add origin git@gitlab.com-Account2:group_name/repo_name.git
        
      3. Account 3

        git remote add origin github.com-Account3:github_username/repo_name.git
        

    Make sure that IdentityFile names are same as you created during ssh key generation.

提交回复
热议问题