Github使用小结
1.ubuntu下安装git环境
- ubuntu 16.04已经自带git ,可以通过下列命令进行安装与检测是否成功安装
- sudo apt-get inst all git  //安装   
 
- //git命令出现代表安装成功(为考证) 
 
- root@forest-E351:/ 
 
- usage: git [--version] [--help] [-C <path>] [-c name=value] 
 
-            [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] 
 
-            [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] 
 
-            [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] 
 
-            <command> [<args>] 
 
-  
 
- These are common Git commands used in various situations: 
 
-  
 
- start a working area (see also: git help tutorial) 
 
-    clone      Clone a repository into a new directory 
 
-    init       Create an empty Git repository or reinitialize an existing one 
 
- 打通本地git与github之间的连接
 设置git的user.name和user.email,便于后面定位git commit的操作对象,姓名和邮箱不需要与github对应,若不操作,则不能进行本地git commit提交。
- git config --global user.name "我填写的是github上用户名称" 
 
- git config --global user.email  "我填写github注册邮件" 
 
- 生成ssh key,用于本地连接上github
- 查看是否已经有了ssh密钥:cd ~/.ssh,如果没有密钥则不会有此文件夹,有则备份删除。
- 生存密钥:$ ssh-keygen -t rsa -C “h××@163.com”
 注:ssh-keygen - 生成、管理和转换认证密钥
 ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment] [-foutput_keyfile]
 -t  指定要创建的密钥类型。可以使用:“rsa1”(SSH-1) “rsa”(SSH-2) “dsa”(SSH-2)
 -C   提供一个新注释   查看公钥文件,最后就是你-C填写的邮箱
 按3个回车,密码为空,最后得到了两个文件:id_rsa和id_rsa.pub,终端会出现如下结果:
 
- Your identification has been saved in /home/forest/.ssh/id_rsa. 
 
- Your public key has been saved in /home/forest/.ssh/id_rsa.pub. 
 
- The key fingerprint is: 
 
- ……………… 
 
- cat  ~/.ssh/id_rsa.pub 
 
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD1MLePx7 
 
- 1IVRowCGKXon1Ucv1xHx//zPO1otu617ru2vLr2kG9rwXOlwYwSV3c 
 
- bH5Ux44yVJiWd+fr7n+re91XYZCa88iY70TSW/9 h××@163.com 
 
- 上传public key到Github账户
 1.登陆github
 2.点击右上方的accounting settings
 3.选择SSH KEY
 4.点击添加ssh key  即为~/.ssh/id_rsa.pub 中的内容
 修改~/.ssh/config  Host github.com Hostname ssh.github.com Port 44
 不修改也可以 直接使用ssh -T git@github.com 测试即可,出现以下结果说明连接成功
- Hi wowforestwow! You‘ve successfully authenticated,  
 
- but GitHub does not provide shell access. 
 
- Connection to github.com closed 
 
 Github使用小结
原文:http://www.cnblogs.com/forest-wow/p/6843067.html