Centos 7.x 搭建Git - Go语言中文社区

Centos 7.x 搭建Git


查看服务器版本

[root@Rui git-2.12.1]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 

yum info git  //查看 yum 源仓库的 Git 信息

在这里插入图片描述
依赖库安装

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker

卸载系统自带的底版本git(1.7.1)

git --version
git version 1.7.1
yum remove git

git-2.12.1 版本下载

链接: https://pan.baidu.com/s/17Crs4WyjUEaKUNxjRT2mmg 提取码: ejmn 
mkdir /usr/local/apps/     #创建apps目录存放git文件
把git-2.12.1 放到apps下
[root@Rui apps]# tar git-2.12.1
[root@Rui apps]# cd git-2.12.1

编译

make prefix=/usr/local/git all
make prefix=/usr/local/git install

添加环境变量 & 使配置立即生效

[root@Rui git-2.12.1]#  echo "export PATH=$PATH:/usr/local/apps/git-2.12.1" >> /etc/profile
[root@Rui git-2.12.1]# source /etc/profile 

设置git 默认路径,防止克隆出错

ln -s /usr/local/git/bin/git-upload-pack /usr/bin/git-upload-pack 

ln -s /usr/local/git/bin/git-receive-pack /usr/bin/git-receive-pack 

创建git用户组 用户及密码

[root@Rui ~]# groupadd git
[root@Rui ~]# useradd git -g git
[root@Rui ~]# passwd git    #给git用户设置密码 
Changing password for user git.
New password:   # 第一次输入密码
BAD PASSWORD: The password is shorter than 7 characters
Retype new password:    # 再次确认密码
passwd: all authentication tokens updated successfully.
[root@Rui ~]# su - git   # 切换git用户
[git@Rui ~]$ 

配置和使用ssh

git config --global user.name "用户名"
git config --global user.email "邮箱"

生成密钥

ssh-keygen -t rsa -C "邮箱"

连续3个回车。如果不需要密码的话。
最后得到了两个文件:id_rsa和id_rsa.pub。

添加密钥到ssh-agent

eval "$(ssh-agent -s)"    # 验证私钥 ssh-agent 是可用的
Agent pid 59566

ssh-add ~/.ssh/id_rsa    # 添加生成的私钥 SSH key 到 ssh-agent。

添加公钥到 github

vim ~/.ssh/id_rsa.pub
复制内容 一会使用

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在linux 测试测:

ssh -T git@github.com

You've successfully authenticated, but GitHub does not provide shell access.
表示成功了

快速使用GIT可参考

https://blog.csdn.net/weixin_38507813/article/details/92004193
版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_38507813/article/details/95681965
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-07 21:04:56
  • 阅读 ( 1356 )
  • 分类:Linux

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢