部署流程
安裝git
<code>$ sudo apt-get install git/<code>
然後創建一個git用戶,用於git服務:
<code>$ sudo adduser git/<code>
創建所需要的repo
<code>$ sudo git init --bare project.git/<code>
將倉庫的所有者修改為git用戶
<code>$ sudo chown -R git:git project.git/<code>
禁用shell登錄
處於安全方面的考慮,剛才創建的git用戶不能使用shell登錄,我們要對它的默認shell進行修改,修改默認shell需要修改/etc/passwd文件
<code>$sudo vim /etc/passwd/<code>
找到git用戶的那一行
<code>git:x:1001:1001:,,,:/home/git:/bin/bash/<code>
將/bin/bash修改為/usr/bin/git-shell:
<code>git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell/<code>
使用
下面就可以使用了
克隆倉庫:
<code>$ git clone ssh://git@xxx.xxx.xxx/home/git/xxxx.git/<code>