git学习总结
1.git在linux操作系统下已经安装无需再次安装。windows操作系统下需要安装,
这部分转载自http://www.cnblogs.com/monodin/p/3268679.html
msysgit是Git for Windows版,其Home Page为:https://git-for-windows.github.io/ 点击页面中“Download”进入下载列表。可根据个人喜好选择下载版本。这里选择下载最新版
二、安装
下载完毕,双击开始安装:
1、除了AdvancedXXX选项,其余全选中
2、选择“Use Git Bash only”
3、选择“Checkout as-is,commit as-is”
4、等待安装完毕。
2.配置git
配置Name和Email
命令格式:git config --global user.name "your name"
git config --global user.email "your email address"
为了提高命令输出的可读性
输入 git config --global color.ui auto
此时进入~/.gitconfig会看到刚才的配置
3.设置SSH KEY
运行一下命令设置ssh key:
ssh-keygen -t rsa -C "your_email@example.com"
会输出Generating public/private rsa key pair.
Enter file in which to save the key
(/Users/your_user_directory/.ssh/id_rsa):(按回车键)
Enter passphrase (empty for no passphrase)(输入密码)
Enter same passphrase again(再次输入密码)
Your identification has been saved in /home/tekkub/.ssh/id_rsa.
Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
……………… 最后得到了两个文件:~/.ssh/id_rsa和~/.ssh/id_rsa.pub
4.添加ssh密钥
在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。打开https://github.com/settings/ssh Add SSH KEY title随便取 Key就是~/.ssh/id_rsa.pub里的全部内容此时你的github注册的主邮箱会收到邮件提醒你The following SSH key was added to your account:.......5.此时就可以用手中的私人密钥与github进行认证和通讯了
输入命令 ssh -T git@github.com 输出 The authenticity of host ‘github.com (x.x.x.x)’ can’t be established.RSA key fingerprint is ....
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘github.com,x.x.x.x′ (RSA) to the list of known hosts.
Hi xxx! You’ve successfully authenticated, but GitHub does not provide shell access
Connection to github.com closed.
6.git操作
建立本地git文件夹 输入git init进行初始化操作