Github multiple accounts one computer always sees one account

前端 未结 4 1194
广开言路
广开言路 2020-12-16 04:15

This is probably not a dup; I have read through many similar problems on StackOverflow but not this issue.

I am trying to use multiple git accounts on Ubuntu Linux a

4条回答
  •  暖寄归人
    2020-12-16 04:58

    To state my assumptions for this answer, it sounds from the question title as if what you really want to do is to be able to push to GitHub being identified as different GitHub users.

    If that's the case, you shouldn't create multiple users on your system just in order to push as different GitHub users over SSH. The right way to do this is to set up two aliases for github.com in ~/.ssh/config that specify different identity files, as described here. For example, you might have in your ~/.ssh/config the following:

    Host github-act1
      HostName github.com
      User git
      IdentityFile /home/whoever/.ssh/id_rsa.act1
    
    Host github-act2
      HostName github.com
      User git
      IdentityFile /home/whoever/.ssh/id_dsa.act2
    

    Then you can add two remotes to your repository:

    git add remote act1 git@github-act1:whoever/whatever.git
    git add remote act2 git@github-act1:whoever/whatever.git
    

    Then if you want to push as one user you can do:

    git push act1 master
    

    ... or as the second account:

    git push act2 master
    

提交回复
热议问题