search

Home  >  Q&A  >  body text

github - How to resolve conflicts between two .ssh keys in git

Currently I use github and the company's gitlab, and github corresponds to my QQ number, and gitlab corresponds to the company's account. And I don't want to add the company's account on Github to obtain the key.
Solve the problem: Refer to online articles and write the config file locally

  # gitlab
Host gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa(对应公司的账号)

# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa2(我的QQ号)

Description of the situation:
1. The problem that occurred is that the name submitted by the company is actually my QQ information, but the SSH key added on gitlab was generated by the company's corresponding account. (I guess the logic is a bit confusing)

2. I checked the local configuration cat ~/.gitconfig. It is the information corresponding to my QQ number!

Question: Why is the .ssh key of the company account configured on gitlab, and the QQ account information is also displayed when submitting the code? Doesn’t gitlab have permission verification

阿神阿神2796 days ago622

reply all(2)I'll reply

  • 为情所困

    为情所困2017-05-02 09:31:48

    You may not understand the difference between push and commit

    push 是将本地库推送到远端,需要权限,sshkey是用来校验是否有push权限的
    commit 只是在本地将改动提交到本地的仓库,不需要权限。.gitconfig里面的用户名和邮箱只是commitThe information corresponding to the author does not have permission control function. You can specify it at will, even if you change it to Steve Jobs, you can submit it

    • git config user.name You can view the username configuration of the current repo

    • git log You can check the email address and user name used to submit historical commits

    ~/.gitconfig is the global configuration of your git. If there is no separate configuration under the project, it will be inherited from the configuration file

    Solution: Just configure it separately in the company project

    cd repo_of_work
    git config user.name 公司用户名
    git config user.email 公司邮箱

    In fact, this is still relatively easy to cause confusion. Once there is a new company project and you forget to configure the company email, a similar situation will occur. It is best to delete the global configuration. In this way, every time there is a new project, the user name and email address will not be configured. The email cannot be committed

    reply
    0
  • PHPz

    PHPz2017-05-02 09:31:48

    Supplementary instructions posted upstairs

    $ git config -l
    $ git config --global -l 
    $ git config --global --unset user.name
    $ git config --global --unset user.email

    reply
    0
  • Cancelreply