零, 下载和安装git for windows
原网址下载比较慢, 这是百度盘下载链接.https://pan.baidu.com/s/1uei5UkY21Ez4YDTlxWh9Gg
安装的时候一直点下一步,
安装成功后,桌面上会出现一个Git Bash的图标快捷键.
打开后,进入下一步操作.
 i
i
一, 设置用户名和邮箱
首先注册一个github账户.
官方指导:First time set up
以我新注册的新账户, 这里代表你,用你的账户替代yourname.
用户名: yourname
邮箱: someone@gmail.com为例.
- 分别复制输入命令, $这个符号不要复制,每复制一行回车.(以下相同), 用你的github账户的用户名和邮箱替代yourname的.
| 1 | $ git config --global user.name "yourname" | 

- 核实下是否设置成功 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18- $ git config user.name 
 #如果反馈出 yourname,就是设置成功!
 $ git config user.email
 #会显示 someone@gmail.com
 gaowei@alpha:~/Documents/English/EnglishGit/01.GitCollection$ git config --list
 user.name=M-DFK
 user.email=gcpu.whisper@gmail.com
 core.repositoryformatversion=0
 core.filemode=true
 core.bare=false
 core.logallrefupdates=true
 core.ignorecase=true
 core.precomposeunicode=false
 remote.origin.url=https://github.com/M-DFK/English.git
 remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
 branch.master.remote=origin
 branch.master.merge=refs/heads/master
二,设置SSH, 连接Github
官方指导:Connect to Github
1. Generating a new SSH key
以下按照步骤复制黏贴到git bash中.
- Paste the text below, substituting in your GitHub email address. - 1 - $ ssh-keygen -t rsa -b 4096 -C "someone@gmail.com" 
- save the SSH key - 1 - Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter] - [Press enter] 是按回车,不要输入任何内容,只按回车键. 
- At the prompt, type a secure passphrase. For more information, see “Working with SSH key passphrases”.(设置密码,输入任意密码) - 1 
 2- Enter passphrase (empty for no passphrase): [Type a passphrase] 
 Enter same passphrase again: [Type passphrase again]- 下面的图片,设置密码的时候,我两次输入的不一致,提示让我重新又设置了一遍. 
 密码可以随意设置,在自己能记住的前提下. 
2. Adding your SSH key to the ssh-agent
- Run ssh-agent - 1 - eval $(ssh-agent -s) 
- Add your SSH private key to the ssh-agent. - 1 - ssh-add ~/.ssh/id_rsa  
三, 添加SSH key到Gibhub账户
- 复制SSH key - 1 
 2
 3
 4
 5
 6
 7
 8
 9- cat ~/.ssh/id_rsa.pub 
 less ~/.ssh/id_rsa.pub
 #回车后,复制以下图片中的内容,'ssh开始,@gmail.com结束'的全部内容.
 #可以右键点复制,也可以用快捷键 Ctrl + Ins (注意不是快捷键 Ctrl + C)
 sudo apt-get install xclip
 # Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
 xclip -sel clip < ~/.ssh/id_rsa.pub
 # Copies the contents of the id_rsa.pub file to your clipboard 
- 在网页中打开Github账户,进入设置(setting 选型)  
- 进入  -  
- 点 新建SSH Key  
- 在空白框中黏贴刚才复制的内容,标题可以命名为日期  
- 单击添加  
- 网站会要求重新登录.  
- 查看设置成功 