Git服务器的搭建
1、 依赖环境
Git需要很多依赖环境:因此安装git需要先安装下列软件
[root@localhost ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel gcc-c++
2、安装git
上传git安装包或者在linux系统下载git
下载地址
https://github.com/git/git/releases
在linux系统下载git:
wget https://github.com/git/git/archive/v2.16.1.tar.gz
解压
[root@localhost ~]# tar -zxvf v2.16.1.tar.gz
3、编译安装
安装命令:(进入git解压目录)
[root@localhost git-2.16.1]# make prefix=/usr/local/git all [root@localhost git-2.16.1]# make prefix=/usr/local/git install
4、查看git
[root@localhost git-2.16.1]# git --version
5、配置环境变量
[root@localhost git-2.16.1]# vi /etc/profile 在最后一行添加 export PATH=$PATH:/usr/local/git/bin
6、配置git
6.1设置用户名和email
[root@localhost git-2.16.1]# git config --global user.name "simba"[root@localhost git-2.16.1]# git config --global user.email "simba1949t@outlook.com"
7、初始化仓库
初始化仓库,仓库名为 test.git
[git@localhost root]$ cd [git@localhost ~]$ git init --bare test.git
始化空的 Git 仓库于 /root/git-2.16.1/test.git/
如图:
附录1 Download for Linux and Unix
It is easiest to install Git on Linux using the preferred package manager of your Linux distribution. If you prefer to build from source, you can find the tarballs on kernel.org.
Debian/Ubuntu
For the latest stable version for your release of Debian/Ubuntu
# apt-get install git
For Ubuntu, this PPA provides the latest stable upstream Git version
# add-apt-repository ppa:git-core/ppa
# apt update; apt install git
Fedora
# yum install git
(up to Fedora 21)
# dnf install git
(Fedora 22 and later)
Gentoo
# emerge --ask --verbose dev-vcs/git
Arch Linux
# pacman -S git
openSUSE
# zypper install git
Mageia
# urpmi git
Nix/NixOS
# nix-env -i git
FreeBSD
# pkg install git
Solaris 9/10/11 (OpenCSW)
# pkgutil -i git
Solaris 11 Express
# pkg install developer/versioning/git
OpenBSD
# pkg_add git
Alpine
$ apk add git
Red Hat Enterprise Linux, Oracle Linux, CentOS, Scientific Linux, et al.
RHEL and derivatives typically ship older versions of git. You can download a tarball and build from source, or use a 3rd-party repository such as the IUS Community Project to obtain a more recent version of git.
Slitaz
$ tazpkg get-install git