mac多git账户续

同时配置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/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,860评论 18 139
  • 文章1: Git 多账户配置使用,同时使用github 和 gitoschina http://blog.csdn...
    ouhoo阅读 1,685评论 0 0
  • 第一章 安装Git工具 下载GitHub for Windows,直接点击安装,安装完成后,可以看到“Git Sh...
    不圆的石头阅读 11,908评论 5 63
  • 简介 什么是git? git是一款开源的分布式版本控制工具 在世界上所有的分布式版本控制工具中,git是最快、最简...
    JonesCxy阅读 1,063评论 0 3
  • 军人,一个伟大的职业。他们为了人民的幸福,为了祖国的安全,舍身忘死,浴血奋战。但军人也是有着血肉之躯的人,...
    李荣宸阅读 295评论 0 2