git伺服器部署

2022-08-02 16:54:13 字數 1277 閱讀 1705

環境描述:

10.1.1.1 centos 6.6 git伺服器

10.1.1.2 centos 6.6 git客戶端

1、搭建git伺服器

1) 安裝git

# yum install -y git

2) 建立git使用者,用於執行git服務

[root@localhost ~]# useradd git

3) 選擇/data/git/learngit.git作為倉庫,初始化倉庫

[root@localhost ~]# mkdir -pv /data/git

[root@localhost ~]# cd /data/git

[root@localhost git]# git init --bare learngit.git >>>>建立裸倉庫

initialized empty git repository in /data/git/learngit.git/

[root@localhost git]# chown -r git.git learngit.git/

4) 收集客戶端的ssh公鑰,並匯入到/home/git/.ssh/authorized_keys檔案中

[root@localhost ~]# mkdir /home/git/.ssh

[root@localhost ~]# touch /home/git/.ssh/authorized_keys

[root@localhost ~]# cat /home/git/.ssh/id_rsa.pub > /home/git/.ssh/authorized_keys

[root@localhost ~]# chmod 700 /home/git/.ssh/

[root@localhost ~]# chmod 600 /home/git/.ssh/authorized_keys

[root@localhost ~]# chown git.git /home/git/.ssh/authorized_keys

[root@localhost ~]# chown git.git /home/git/.ssh/

5) 出於安全考慮,禁止git使用者登入 shell

[root@localhost ~]# usermod -s /usr/bin/git-shell git

2、在客戶端測試git轉殖

方法2:

[root@git-client data]# git clone [email protected]:/data/git/learngit.git /testdata/

部署Git伺服器

yum安裝git軟體。root git server yum y install git 安裝git初始化乙個空倉庫。root git server mkdir p var lib git 為git建立倉庫目錄 root git server git init var lib git project...

Git 之一 Git伺服器部署

下面簡單介紹在centos 7上部署git 倉庫。一 安裝git及建立使用者 配置郵箱 安裝git yum install git 建立使用者 略。一般單獨建立乙個git 使用者,並禁止使用者登入,參考 安裝完git後配置使用者名稱 郵箱 git config global user.name au...

在伺服器上部署Git

發現乙個git學習資料 講的比較詳細,分享一 下。開始架設 git 伺服器前,需要先把現有倉庫匯出為裸倉庫 即乙個不包含當前工作目錄的倉庫。做法直截了當,轉殖時用 bare選項即可。裸倉庫的目錄名一般以.git結尾,像這樣 git clone bare my project my project.g...