这里的git指git的客户端,而不是像github这样的服务端。
1git简介
Git是一款免费、开源的分布式版本控制系统。
特点:
Git是一个开源的分布式版本控制系统,可以有效、高速的处理从很小到非常大的项目版本管理。
2git安装











安装好之后在桌面点击右键就可以看到辣,我们选择Git Bash Here就可以打开它的控制台了~
3git基础配置
1)配置用户名(提交时会引用)
git config --global user.name "自己的用户名"
提交代码之后可以看到提交的版本还有用户名~
--global可加可不加,如果加就是全局的,如果不加就在个性化的本地的仓库中。

2)配置邮箱(提交时会引用)
git config --global user.email "自己的邮箱"

3)编码配置
git config --global gui.encoding utf-8 //避免git gui中的中文乱码

git config --global core.quotepath off //避免git status显示的中文文件名乱码

git config --global core.ignorecase false //忽略大小写:关闭

4)git ssh key pair配置
1.输入命令:ssh-keygen -t rsa -C "你的邮箱"
2.然后一路回车,不要输入任何密码之类,生成ssh key pair。

3.继续输入命令:
ssh-add ~/.ssh/id_rsa //add

果然出现了这个问题:

按照上上图中的方法解决,成功啦:

4.cat ~/.ssh/id_rsa.pub //查看

5.再把其中公钥的内容复制到剪切板。
6.本教程使用的oschina的gitlab,具体根据自己情况来定。
7.登录对应的gitlab右上角个人资料。
进入个人的SSH公钥配置,把刚复制的公钥添加进去,确定提交。
注册了一个账号:

进入设置:

选择SSH公钥:

将公钥粘贴进去,保存:

更多关于SSH公钥的原理可以参考这篇文章:SSH公钥原理
5)其他配置
git config --global merge.tool "kdiff3" //我们没有装KDiff3就不用设这一行
git config --global core.autocrlf false //让Git不要管Windows/Unix换行符转换的事

4git验证
执行git --version命令,出现版本信息,则说明安装成功。

5git常用命令
1)切换分支:git checkout 分支名
2)拉取:git pull
3)提交:git push
更多git基础的学习可以看慕课网的视频教程:版本管理工具介绍—Git篇
网友评论