1、浏览器登录github账号,设置里面找ssh秘钥,new 一个秘钥,先用git bash生成一个秘钥,
假设没有秘钥,新生成秘钥默认在安装路径下的.ssh文件夹下。
Administrator@smy MINGW64 ~
$ ssh-keygen -t rsa -C "你git账号绑定的邮箱"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):(此处直接回车)
Enter passphrase (empty for no passphrase):(此处直接回车)
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.(默认生成在你安装目录下.ssh文件下)
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.(默认生成在你安装目录下.ssh文件下)
The key fingerprint is:
SHA256:sh9W/OO5fU2FheVa4srercNKiAi+qWOpQg3rnExD6KE 你git账号绑定的邮箱
The key's randomart image is:
+---[RSA 2048]----+
| o.|
| ...|
|. .oo|
|.+ . ..+.|
|+ = . . S o o .|
|E* o . + o + . .|
|* o.. o + . *. ..|
|.=+ o o . + =o.o|
|oo.oo . *o++.|
+----[SHA256]-----+
把生成的pub文件的内容全部复制,是全部复制然后粘贴到ssh秘钥处,并设置title用来区分不同的设备。
2、git bash连接github
Administrator@smy MINGW64 ~
$ ssh -T git@github.com(拷贝此命令直接回车)
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes(输入yes)
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':(此处自己设置密码会输入两次)
Received disconnect from 192.30.255.113 port 22:11: Bye Bye
Connection to github.com closed by remote host.
3、下载一个github上的项目
Administrator@smy MINGW64 /h/smy/github
$ git clone 输入要克隆的地址
Cloning into 'Test'...
remote: Counting objects: 8, done.
remote: Total 8 (delta 0), reused 0 (delta 0), pack-reused 8
Unpacking objects: 100% (8/8), done.
4、推送本地文件去remote仓库
git add .
git commit -m '注释说明'
git push -u origin master