1.百度搜索下载git,官网可能很慢,我在百度软件里面下载的。当然可能不是最新版本。一路回车安装就好。
2.设置本机git的用户名和邮箱地址
查看当前电脑是否设置了用户名称
$ git config user.name
如果没有会返回空
设置当前用户名称
$ git config --global user.name "Gabriel_wei"
查看当前电脑用户名是否 设置成功
$ git config use.name
设置邮箱地址
$ git config --global user.email "123@123.com
查看当前的所有配置项
$ git config --list
3.设置一个ssh链接到我们的GitHub
3.1查看以前是否生成过ssh
$ cd ~/.ssh
如果没有会返回空
bash: cd: /c/Users/Administrator/.ssh: No such file or directory
3.2生成SSH
注意-C后面没有空格
$ ssh-keygen -t rsa -C"123@123.com"
一路回车就行,他会返回
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Created directory '/c/Users/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:3zie8yG2e3QNBnqUVod/cZBm3tcKKapEPs1FFfl/RPo 123@123.com
The key's randomart image is:
+---[RSA 2048]----+
| .o+ oo|
| . = *o.|
| . o O =+|
| . + + *.F|
| o oSo o o **|
| + +. . ..E|
| . o . .o++o|
| . ..o+=|
| oo o|
+----[SHA256]-----+
3.3登录GitHub,将我们生成的秘钥填入GitHub。在头像那里点击选择setting(设置),进入如下页面
3.4秘钥的存放地址
我得路径是这个
C:UsersAdministrator.ssh
里面有两个文件,一个id_rsa,一个id_rsa.pub,后面这个就是我们连接GitHub的ssh,用记事本打开复制粘贴就行。
3.5接着3.4的步骤来,点击New SSH key,如图所示,输入3.4的秘钥就好
3.6测试一下是否可以链接到GitHub
输入
$ ssh git@github.com
正常情况下面会这么回复
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGdafdpRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi Gabrielkaliboy! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
自此,我们成功新建了一个SSH,并且链接到了GitHub。