建立GitHub远程仓库

GitHub官网:https://github.com
 
一、创建github远程仓库
 
##当把自己的本地git仓库链接远程的git仓库,实现通过将本地的git仓库里文件推送到别的仓库
 
1:到GitHub官网注册账号,然后在网站上创建github远程仓库

 

 

 

 

2:在本地git机器上,ssh-keygen命令生成秘钥对,将公钥放在网站上的githu远程仓库
[root@ghs ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
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:
e0:6b:96:a2:66:56:10:8f:35:e0:50:a6:a6:64:8c:25 root@ghs
The key's randomart image is:
+--[ RSA 2048]----+
|E.=.             |
|oB. o            |
|o=.= ..          |
|= o .. .         |
|.  .  . S        |
|    .  o         |
|   .. =          |
|  +. +           |
| +.              |
+-----------------+
 
3:拷贝公钥内容到远程GitHub仓库
[root@ghs ~]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA/cl2F7nwz7jDIyvNiwJg1lOfJDvMJew0Iy9N1aOmiXOf9xmQtNI0JZ3MJKpyBaLZPL3vsn0wcrIWjKiEyrg2j6niJbsjpQ/9N0958U02XoOhMiPvJljJqaTUO3ailiLJJNHsDrX6SbKIfLxGts0XYiwABVyJoBM7WHmnxoc8zESt9eNd+C+uVJ7Sg3KUV30nS+dhxKyAzxcBWIQp4CvMEFoIWOFTGBhSePDtLOXsAItJafCGQZ98+LAUTeFfzO+FMXA8XBtHP8uprEqI3q5qb12bzzVftZQPnAJVJVIjButWsa/QXquvHqYIavMe8gK2YQMmBPcF+gPXx4+mk7O4gQ== root@ghs
 
4:复制到远程仓库的key里

 

 

 

 

5:在本地git仓库有个1.txt文件
[root@ghs aaa]# cat 1.txt
ehrahjfhsjfa
sfhajsfja
12131241
 
 
6:链接github远程仓库
[root@ghs aaa]# git remote add origin git@github.com:guhongshun/aaa.git
 
 
7:上传本地文件到github远程仓库里
[root@ghs aaa]# git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 227 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:guhongshun/aaa.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
 
 
8:查看远程仓库上,1.txt文件是否推送成功
远程仓库显示下面的内容和本地仓库一致,侧成功;当下次在本地仓库推送时直接git push

 

 

posted @ 2019-10-11 20:18  一颗小豆子  阅读(627)  评论(0)    收藏  举报