2 Star 1 Fork 0

zhrun8899 / learning-notes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
git-centos7安装.txt 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
zhrun8899 提交于 2019-08-15 14:35 . 20190815 commit
Git 服务器搭建(源码)
1、最新git源码下载地址:
https://github.com/git/git/releases
https://www.kernel.org/pub/software/scm/git/
可以手动下载下来在上传到服务器上面
2 移除旧版本git
centos自带Git,7.x版本自带git 1.8.3.1(应该是,也可能不是),
安装新版本之前需要使用yum remove git卸载(安装后卸载也可以)。
[root@Git ~]# git --version ## 查看自带的版本git version 1.8.3.1
[root@Git ~]# yum remove git ## 移除原来的版本
3 安装所需软件包
[root@Git ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[root@Git ~]# yum install gcc-c++ perl-ExtUtils-MakeMaker
解决:/bin/sh: autoconf: command not found
[root@Git ~]# yum install install autoconf automake libtool
解决 :Can't locate ExtUtils/MakeMaker.pm
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker cpan
下载&安装
[root@Git ~]# cd /usr/src
[root@Git ~]# wget https://www.kernel.org/pub/software/scm/git/git-2.7.3.tar.gz
5 解压
[root@Git ~]# tar xf git-2.7.3.tar.gz
6 配置编译安装
[root@Git ~]# cd git-2.7.3
[root@Git ~]# make configure
[root@Git ~]# ./configure --prefix=/usr/git ##配置目录
[root@Git ~]# make profix=/usr/git
[root@Git ~]# make install
7 加入环境变量
[root@Git ~]# echo "export PATH=$PATH:/usr/git/bin" >> /etc/profile
[root@Git ~]# source /etc/profile
8 检查版本
[root@Git git-2.7.3]# git --version
git version 2.7.3
===================================================================================
Git 服务器搭建(yum)
上一章节中我们远程仓库使用了 Github,Github 公开的项目是免费的,但是如果你不想让其他人看到你的项目就需要收费。
这时我们就需要自己搭建一台Git服务器作为私有仓库使用。
接下来我们将以 Centos 为例搭建 Git 服务器。
1、安装Git
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
$ yum install git
接下来我们 创建一个git用户组和用户,用来运行git服务:
$ groupadd git
$ useradd git -g git
2、创建证书登录
收集所有需要登录的用户的公钥,公钥位于id_rsa.pub文件中,把我们的公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
如果没有该文件创建它:
$ cd /home/git/
$ mkdir .ssh
$ chmod 700 .ssh
$ touch .ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys
3、初始化Git仓库
首先我们选定一个目录作为Git仓库,假定是/home/gitrepo/runoob.git,在/home/gitrepo目录下输入命令:
$ cd /home
$ mkdir gitrepo
$ chown git:git gitrepo/
$ cd gitrepo
$ git init --bare runoob.git
Initialized empty Git repository in /home/gitrepo/runoob.git/
以上命令Git创建一个空仓库,服务器上的Git仓库通常都以.git结尾。然后,把仓库所属用户改为git:
1
https://gitee.com/zhrun8899/learning-notes.git
git@gitee.com:zhrun8899/learning-notes.git
zhrun8899
learning-notes
learning-notes
master

搜索帮助