mac多git账户续

2017-09-22  本文已影响0人  ouhoo

同时配置oscine和github

生成不同的rsa key文件

举例:

mymac@mymacdeMacBook-Pro:~/.ssh$ ssh-keygen -t rsa -C "xx@xxx.com”

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/mymac/.ssh/id_rsa): id_rsa_xxxgitlib

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in id_rsa_xxxgitlib.

Your public key has been saved in id_rsa_xxxgitlib.pub.

The key fingerprint is:

SHA256:kc4U5Ig+3K+HXdLswXH4zDEXHjZ5uG5S1F8Fpwxx@xxx.com

分别在两个网站配置public key

执行

localhost:.ssh mymac$ ssh -T git@git.oschina.net

Welcome to Git@OSC, jrrx!

localhost:.ssh mymac$ ssh -T git@github.com

Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

(1)如果不成功,那么先删除kknow_hosts文件,然后执行ssh-add -D,

(2)然后再分别添加ssh-add rsafile

localhost:.ssh mymac$ ssh-add id_rsa_github

Identity added: id_rsa_github (id_rsa_github)

localhost:.ssh mymac$ ssh-add id_rsa_oschina

Identity added: id_rsa_oschina (id_rsa_oschina)

localhost:.ssh mymac$ ssh-add -l

2048 SHA256:3aGW/B+hBNINi+nsVvY7unV0u4CtIrbzkRg3Cm1E id_rsa_github (RSA)

2048 SHA256:d0Qk0OQxZtGOGjM+CLIA1kr7tNbHcNge+wxT5A8g id_rsa_oschina (RSA)

git commit -m “this is the commit comment”的时候报错

localhost:Learn-SpringBoot mymac$ git commit -m "add new file readme.txt"

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

to set your account's default identity.

Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'mymac@localhost.(none)')

由于我是多账户,所以我在仓库的根目录下单独添加,

localhost:Learn-SpringBoot mymac$ git config user.name "ouhoo"

localhost:Learn-SpringBoot mymac$ git config user.name

ouhoo

localhost:Learn-SpringBoot mymac$ git config user.email "ouhoo@qq.com"

localhost:Learn-SpringBoot mymac$ git config user.email

puhoo@qq.com

localhost:Learn-SpringBoot mymac$ git config --list

Git全局配置和单个仓库的用户名邮箱配置http://blog.csdn.net/luohai859/article/details/50679859

Git配置用户名与邮箱http://www.cnblogs.com/gudi/p/6597660.html

GithubHelphttps://help.github.com/articles/error-permission-denied-publickey/

上一篇 下一篇

猜你喜欢

热点阅读