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(對應(yīng)公司的賬號)
# 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
閉關(guān)修行中......
You may not understand the difference between push and commit
push
是將本地庫推送到遠端,需要權(quán)限,sshkey
是用來校驗是否有push權(quán)限的 commit
只是在本地將改動提交到本地的倉庫,不需要權(quán)限。.gitconfig
里面的用戶名和郵箱只是commit
The 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
Supplementary instructions posted upstairs
$ git config -l
$ git config --global -l
$ git config --global --unset user.name
$ git config --global --unset user.email