GitHub: Multiple account setup

后端 未结 4 1174
野性不改
野性不改 2020-12-08 17:53

I am trying since more than 3 hours to setting up multiple account for github and litteraly tired. I have tried out almost all possible way describe here, github and article

4条回答
  •  醉话见心
    2020-12-08 18:31

    So according to @VonC's answer here what I have done.

    1. I have generate ssh key for another account and added with id_rsa_ac2 (where ac2 is for second account)
    2. Than just cross checked either it works with ssh -T ac2.github.com
    3. Created config file (without extention) in /c/Users/yourname/.ssh/ directory

    Here is the code what I used for config file

    #Account one
    Host github.com
        HostName github.com
        PreferredAuthentications publickey
        IdentityFile /c/Users/yourname/.ssh/id_rsa
        User git
    
    #Account two
    Host ac2.github.com
        HostName github.com
        PreferredAuthentications publickey
        IdentityFile /c/Users/yourname/.ssh/id_rsa_ac2
        User git
    

    So now once you done this you can start to use both account as you need.

    for main account I added remote as origin with git remote add origin git@github/youraccount/rep.git Than to push use git push origin master this will upload to your first account.

    To add remote for second (ac2) account used git remote add ac2 ac2.github/yoursecondaccount/rep.git Than to push use git push ac2 master this will upload to the second (ac2) account.

    To check if it has added remote use git remote -v and incase if you want to remove anyone than use git remote rm origin where origin is your added remote.

    Hope this information will helps to other who is having the same issue.

    Thanks again to @VonC

提交回复
热议问题