确定git已经完成安装

image-20221022161937577

配置用户名称跟邮箱

配置

1
2
3
xuwei@xuweideMacBook-Pro ~ % git config --global user.name xuwei
xuwei@xuweideMacBook-Pro ~ % git config --global user.email 2427340869@qq.com
xuwei@xuweideMacBook-Pro ~ % git config -global push.default simple

检查

1
2
3
4
5
6
7
xuwei@xuweideMacBook-Pro ~ % git config -l
credential.helper=osxkeychain
safe.directory=/opt/homebrew/Homebrew/Library/Taps/homebrew/homebrew-core
safe.directory=/opt/homebrew/Homebrew/Library/Taps/homebrew/homebrew-cask
user.name=xuwei
user.email=2427340869@qq.com
push.default=simple

生成ssh相关的密钥

1
xuwei@xuweideMacBook-Pro ~ % ssh-keygen -t rsa -C 2427340869@qq.com

一直回车 ,回车到啥也不出为止,然后打开 id_rsa.pub 这个文件

image-20221022163410456

打开 id_rsa.pub

1
xuwei@xuweideMacBook-Pro ~ % open ~/.ssh

image-20221022163629571

image-20221022163748366

关联github

image-20221022164159219

测试是否ok

1
2
3
4
5
6
7
8
9
xuwei@xuweideMacBook-Pro ~ % ssh git@github.com
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
PTY allocation request failed on channel 0
Hi weishao-996! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.