# choose a directory to store installation package cd /usr/local/src
# download package (search for a stable installation package in https://www.kernel.org/pub/software/scm/git/) wget https://www.kernel.org/pub/software/scm/git/git-2.14.1.tar.xz # unzip tar -zvxf git-2.14.1.tar.gz # go to git directory cd git-2.14.1
# compile make all prefix=/usr/local/git # install to /usr/local/git make install prefix=/usr/local/git
# init cd /data/repositories git init --bare test.git
# set up user access for git repository chown -R gituser:gituser /data/repositories chmod 755 /data/repositories # 查找 git-shell 所在目录,edit /etc/passwd file,the last line should be changed as follows gituser:x:500:500::/home/gituser:/usr/local/git/bin/git-shell
If follow the steps above, the location will be /usr/local/git/bin/git-shell, use which git-shell command to check the location
由于安全目的, 限制git账号的ssh连接只能是登录git-shell
use git service
1 2 3
# 克隆 test repo 到本地 cd ~ git clone gituser@<your CVM IP address>:/data/repositories/test.git