源码编译git-go
2018.8.29
安装指定版本的git
一,安装
编译前准备:
依赖库
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
编译工具
yum install gcc perl-ExtUtils-MakeMaker
下载
cd /usr/local/src
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.7.5.tar.gz
tar -zvxf git-2.7.5.tar.gz
执行编译
make all prefix=/usr/local/git
编译完成后, 安装到 /usr/local/git 目录下
make install prefix=/usr/local/git
配置环境变量
echo 'export PATH=$PATH:/usr/local/git/bin' >>/etc/profile.d/git.sh
source /etc/profile.d/git.sh
查看版本
git version
创建账号密码
useradd -m git
passwd git
二 使用
创建 git 仓库并初始化
mkdir -p /data/repositories
cd /data/repositories/ && git init --bare test.git
配置用户权限
chown -R git:git /data/repositories
chmod 755 /data/repositories
修改 gituser 的登录 shell 为/usr/local/git/bin/git-shell
git:x:500:500::/home/gituser:/usr/local/git/bin/git-shell
客户端使用
https://git-scm.com/book/zh/v1/%E8%B5%B7%E6%AD%A5-%E5%88%9D%E6%AC%A1%E8%BF%90%E8%A1%8C-Git-%E5%89%8D%E7%9A%84%E9%85%8D%E7%BD%AE
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
git clone git@ip:/data/repositories/test.git
输入账号密码
go
$ curl -O https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz
$ tar -C /usr/local -zxvf go1.9.linux-amd64.tar.gz
$ mkdir -p ~/go/src
$ echo "export GOPATH=$HOME/go" >> ~/.bashrc
$ echo "export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin" >> ~/.bashrc
$ source ~/.bashrc
$ go version
进程后台运行
让进程在后台运行更可靠的几种方法
https://www.ibm.com/developerworks/cn/linux/l-cn-nohup/index.html