GitHub

 

windows:

1.首先下载 gitbash for win (https://gitforwindows.org/),并安装

 

2.bash操作如下(bash命令行操作)(完全复制我自己执行的bash)

 

7413@PC2124 MINGW64 ~

$ ssh-keygen -t rsa -C "n*****s@163.com"             ###此处输入(第一步)
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/7413/.ssh/id_rsa):   ####ras提示证书文件储存处,接下来到第二步
Created directory '/c/Users/7413/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/7413/.ssh/id_rsa.
Your public key has been saved in /c/Users/7413/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:b2bxa7jjs9TeMhWKqrhdjS7XkXW4SFYleXEbV0k+ql0 napoleo54css@163.com
The key's randomart image is:
+---[RSA 2048]----+
|            .o++*|
|            o.oo+|
|           . o + |
|          o o + .|
|        So.= = E |
|         +=+= o  |
|        ooB+oo   |
|     o.oo==.+o   |
|    o.o+..+*oo.  |
+----[SHA256]-----+

(在此期间把密钥文件中的密钥全部复制,到网站setting 中 ssh中创建新的密钥,名字随意,粘贴密钥进去,保存)

 

 

 

 

 

7413@PC2124 MINGW64 ~

$ ssh -T git@github.com       #########确认密钥是否建立(第二步
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? y  (第三步,此处输入yes,输入y,会继续提示输入yes,确认保持连接)
Please type 'yes' or 'no': yes 
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
Hi ChenShisen! You've successfully authenticated, but GitHub does not provide shell access.    ###成功提示


7413@PC2124 MINGW64 ~
$ git config --global user.name "Chen*****"     ####输入用户名(第四步)


7413@PC2124 MINGW64 ~
$ git config --global user.email "n******s@163.com"  ######输入邮箱(第五步)


7413@PC2124 MINGW64 ~
$ cd D/gitcode                                 ####进入本地仓库,gitcode是在本地建的文件夹,即本地git仓库根文件(第六步)

7413@PC2124 MINGW64 /D/gitcode
$ git clone https://github.com/Chen******/test.git     #####克隆git中的代码仓库到本地仓库(第七步)
Cloning into 'test'...
warning: You appear to have cloned an empty repository.


7413@PC2124 MINGW64 /D/gitcode
$ ls                                ##看克隆是否成功,查看文件夹(第八步)
test/


7413@PC2124 MINGW64 /D/gitcode/test (master)
$ git add testfile                             #添加本地的文件到云端(第九步)

7413@PC2124 MINGW64 /D/gitcode/test (master)
$ git commit -m "hahahahhahah"      #####提交 + ”备注**可省略备注“(第十步)
[master (root-commit) 3911329] hahahahhahah
 1 file changed, 1 insertion(+)
 create mode 100644 testfile/hahahh.txt


7413@PC2124 MINGW64 /D/gitcode/test (master)
$ git push origin master              ########确认提交(这步提交后,会出现登陆GitHub的窗口,输入账号163.com,密码54321)(第十一步)
Counting objects: 4, done.
Writing objects: 100% (4/4), 257 bytes | 257.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To https://github.com/Chen*****/test.git
 * [new branch]      master -> master

7413@PC2124 MINGW64 ~

$ ssh-keygen -t rsa -C "n*****@163.com"             ###此处输入(第一步)
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/7413/.ssh/id_rsa):   ####ras提示证书文件储存处,接下来到第二步
Created directory '/c/Users/7413/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/7413/.ssh/id_rsa.
Your public key has been saved in /c/Users/7413/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:b2bxa7jjs9TeMhWKqrhdjS7XkXW4SFYleXEbV0k+ql0 napoleo54css@163.com
The key''s randomart image is:
+---[RSA 2048]----+
|            .o++*|
|            o.oo+|
|           . o + |
|          o o + .|
|        So.= = E |
|         +=+= o  |
|        ooB+oo   |
|     o.oo==.+o   |
|    o.o+..+*oo.  |
+----[SHA256]-----+

(在此期间把密钥文件中的密钥全部复制,到网站setting 中 ssh中创建新的密钥,名字随意,粘贴密钥进去,保存)




7413@PC2124 MINGW64 ~

$ ssh -T git@github.com       #########确认密钥是否建立(第二步)
The authenticity of host ''github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? y  (第三步,此处输入yes,输入y,会继续提示输入yes,确认保持连接)
Please type 'yes' or 'no': yes 
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
Hi ChenShisen! You''ve successfully authenticated, but GitHub does not provide shell access.    ###成功提示


7413@PC2124 MINGW64 ~
$ git config --global user.name "Chen**"     ####输入用户名(第四步)


7413@PC2124 MINGW64 ~
$ git config --global user.email "n*****s@163.com"  ######输入邮箱(第五步)


7413@PC2124 MINGW64 ~
$ cd D/gitcode                                 ####进入本地仓库,gitcode是在本地建的文件夹,即本地git仓库根文件(第六步)

7413@PC2124 MINGW64 /D/gitcode
$ git clone https://github.com/Chen****/test.git     #####克隆git中的代码仓库到本地仓库(第七步)
Cloning into 'test'...
warning: You appear to have cloned an empty repository.


7413@PC2124 MINGW64 /D/gitcode
$ ls                                ##看克隆是否成功,查看文件夹(第八步)
test/


7413@PC2124 MINGW64 /D/gitcode/test (master)
$ git add testfile                             #添加本地的文件到云端(第九步)

7413@PC2124 MINGW64 /D/gitcode/test (master)
$ git commit -m "hahahahhahah"      #####提交 + ”备注**可省略备注“(第十步)
[master (root-commit) 3911329] hahahahhahah
 1 file changed, 1 insertion(+)
 create mode 100644 testfile/hahahh.txt


7413@PC2124 MINGW64 /D/gitcode/test (master)
$ git push origin master              ########确认提交(这步提交后,会出现登陆GitHub的窗口,输入账号163.com,密码54321)(第十一步)
Counting objects: 4, done.
Writing objects: 100% (4/4), 257 bytes | 257.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To https://github.com/Chen****/test.git
 * [new branch]      master -> master



linux:

[root@localhost .ssh]# git config --global user.name "gitname"  第一步
[root@localhost .ssh]# git config --global user.eamil "n****@163.com"  第二步
[root@localhost .ssh]# ssh-keygen -t rsa -C "n****@163.com"  第三部创建密钥
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):  使用默认地址

Enter passphrase (empty for no passphrase):    以后操作git的密码,这里默认无
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:dCSdXKJT3yTR+S8E/K7s9EHb8HjTC3DH7W1zXYKEVgs n****@163.com
The key s randomart image is:
+---[RSA 2048]----+
|        .oE+=o.. |
|         =+*o=o  |
|        + + +o.. |
|       . + . .+ o|
|        S  ..+o+o|
|            o.+O*|
|           ..o++@|
|           .o..+=|
|           .. .. |
+----[SHA256]-----+
[root@localhost .ssh]# ls
id_rsa  id_rsa.pub  known_hosts
[root@localhost .ssh]# vi id_rsa.pub  #打开复制密钥,在GitHub网站setting中创建新连接
[root@localhost .ssh]# ssh -T git@github.com   #检查连接是否成功
Hi Chen****! You''ve successfully authenticated, but GitHub does not provide shell access.  

接下来和windows相同

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值