同一客户端设置多个git账户

RT,我想在我本地设置多个git账户,同时应对gitlab/github的工作。
我按照搜索的教程来做了,可以push到github远端了,虽然名字跟我设置的对的上,但是github commit log上的名字却无法对应上我的账户,也就是名字上没有链接。请问是我哪里姿势不对?

Host github.com
        HostName github.com
        User gitname
        PreferredAuthentications publickey
        IdentityFile /Users/xx/.ssh/id_rsa_github
Host gitlab.com
        HostName gitlab
        User git
        PreferredAuthentications publickey
        IdentityFile /Users/xx/.ssh/id_rsa 

我有首先unset全局设置,然后本地设置,名字跟github账户的名字对的上,但是push上去之后就是不能识别。顺带ssh keys也设置了。

PS:我校验了应该是可以连接到GitHub的。

▶ ssh -T git@github.com
Hi RyanLiu0235! You've successfully authenticated, but GitHub does not provide shell access.
阅读 3.3k
3 个回答

在项目的.git文件夹所在的目录下执行以下命令:

git config user.name xxxxxx
git config user.email xxxxx@xxx.xxx

然后通过 git config --list 查看配置生效了没有。
这样你commit到github上的帐户就是你刚才添加的。

commit log上的名字是你设置的

git config --global user.name "Your Name"
git config --global user.email "email@example.com"

可以尝试git config --local

新手上路,请多包涵
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题