Linux 下搭建git 服務器
環境: 服務器 centos7.3 +git1.8.3.1
客戶端 centos7.2 +git1.8.3.1
服務器配置;
1.安裝git yum install git -y
2.創建git用戶
[[email protected] ~]# id git
id: git: no such user
[[email protected] ~]# useradd git
[[email protected] ~]# id git
uid=1001(git) gid=1001(git) groups=1001(git)
為了安全起見,可以只允許git使用git命令
sed -i ‘/^git/s#/bin/bash#/usr/bin/git-shell#g‘ /etc/passwd
3.在服務端創建git倉庫
把/data/git/test.git設置為GIT倉庫,並修改屬主屬組為git
[[email protected] ~]# mkdir -p /data/git/test.git
[[email protected] ~]# git init --bare /data/git/test.git #--bare參數創建目錄結構
Initialized empty Git repository in /data/git/test.git/
[[email protected]
[[email protected] ~]# cd /data/git/test.git/
[[email protected] test.git]# ll
total 12
drwxr-xr-x. 2 git git 6 Jun 28 22:57 branches
-rw-r--r--. 1 root root 66 Jun 28 22:58 config
-rw-r--r--. 1 git git 73 Jun 28 22:57 description
-rw-r--r--. 1 git git 23 Jun 28 22:57 HEAD
drwxr-xr-x. 2 git git 242 Jun 28 22:57 hooks
drwxr-xr-x. 2 git git 21 Jun 28 22:57 info
drwxr-xr-x. 4 git git 30 Jun 28 22:57 objects
drwxr-xr-x. 4 git git 31 Jun 28 22:57 refs
客戶端配置:
1.安裝git yum install git -y
2.配置免密鑰登錄
[[email protected]