参考:https://yq.aliyun.com/articles/521363?spm=a2c4e.11163080.searchblog.116.4f762ec1wevjtK
一.安装
Git分为服务端和客户端,服务端有github、gitlab、码云等等,客户端就是连接服务端的各种工具,比如Linux/mac安装的是git命令,windows安装的是客户端软件等等。
Git是一款免费的分布式版本管理系统,git可以进行项目的版本管理。
#1.查看git版本,卸载旧版本(如果没有安装git请直接到下一步)
git --version
yum remove git
#2.安装依赖软件
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
yum install gcc perl-ExtUtils-MakeMaker
#3.下载git并解压:
wget https://www.kernel.org/pub/software/scm/git/git-2.21.0.tar.gz
#4.编译安装:安装git到/usr/local/git下
make prefix=/usr/local/git all
make prefix=/usr/local/git install
#5.测试版本
git --version
#查看git版本,发现还是旧版本,这是因为它默认使用了"/usr/bin"下的git。我们要把编译安装的git路径放到环境变量里,让它替换"/usr/bin"下的git。为此我们可以修改“/etc/profile”文件
#在环境变量当中添加
export PATH=/usr/local/git/bin:$PATH
#使生效
source /etc/profile
#再次查看版本已经使最新的版本了。
二.配置
1.
#配置用户信息
#global表示此台机器上的所有的git仓库都会使用这个账户
git config --global user.name "superzqbo" #在码云上回显示提交人为superzqbo
git config --global user.email "superzqbo@163.com"
#使用git config --list查看配置有没有成功,如果成功,git config --list会显示出来
#其他配置
git config --global merge.tool "kdiff3" #若没有安装kdiff3则无需配置此行
git config --global core.autocrlf false #提示git不要管Windos/Linux换行的事情(因为提示的代码肯能是Linux或者windos提交的)
2.
#编码配置
git config --global gui.encoding utf-8 #避免git gui当中的中文乱码问题
git config --global core.quotepath off #避免git status显示的中文文件名乱码
git config --global core.ignorecase false #若我们使用的是windows的gitbash的话,需要添加此句
3.
#git ssh key pair
#ssh key可以让客户端与码云服务器安全加密连接,而且不需要输入密码。
#在Linux或者在windows的gitbash命令行窗口当中键入如下的命令
ssh-keygen -t rsa -C "superzqbo@163.com"
然后一路回车,不要输入任何的密码,生成ssh key pair
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub
4.
将生成的公钥复制到码云/gitlab/github等托管工具的SSH当中
➜ ~ git config --global user.name "superzqbo"
➜ ~ git config --global user.email "superzqbo@163.com"
➜ ~ git config --global core.autocrlf false
➜ ~ git config --global gui.encoding utf-8
➜ ~ git config --global core.quotepath off
➜ ~ ssh-keygen -t rsa -C "superzqbo@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/laochaochunfengting/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/laochaochunfengting/.ssh/id_rsa.
Your public key has been saved in /Users/laochaochunfengting/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:m52s3tnp15Xei0YLQGqvp9n1XnXlapkgaHR5fBqIqec superzqbo@163.com
The key's randomart image is:
+---[RSA 2048]----+
| |
| + + |
| * + + . .|
| = + . + ..|
| o S o o =|
| + * + o =+|
| E +.o Boo|
| .o+.o.=+.o|
| +=.o.*= ..|
+----[SHA256]-----+
➜ ~ ssh-add ~/.ssh/id_rsa
Identity added: /Users/laochaochunfengting/.ssh/id_rsa (superzqbo@163.com)
➜ ~ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD7W6NjRbciRQgNZK9zZq9nElqWOnGvVn37aoPj5m/RyFyyytPKzlc9Jm6+VEcpgRzr6kCabSVO+WpBgH22H9dTqHwSPDqMcDnJXMgZqnvXl/5+jCg8yZVbV5xQGnLWFrmJrvInFjhlF+Jdu23b+unlIama3k6iMu2xUw2eQ5nsSIuFQBzxE3ddsgEeyIW16gTdhMfpuBUejK0DZdpaoMKGGayN3/w+1DhEfP+axPGy7SErt0N0cT7hJsB4qBbGOLJGlRbsyPvNwKq16Ye6GAYLXWoB11cNqcrEk1cK0qQjnjKrCgQqqVSsLCNMOgeyCSN/7m6MSapdF9Y5XbRo7Agl superzqbo@163.com
➜ ~


网友评论