初始化倉庫:
- cd 到一個路徑
- 初始化一個新的倉庫 git init --bare test.git //(test.git 是倉庫的名稱)
- 新建一個用戶用來管理 sudo adduser git
- 修改倉庫的所有權(quán)(屬主屬組) sudo chown git.git test.git
- 開啟ssh服務(wù) 如果沒有sudo apt-get install openssh-server
sudo /etc/init.d/ssh start - 創(chuàng)建的git用戶不允許登錄shell,這可以通過編輯/etc/passwd
文件完成。找到類似下面的一行:
git:x:1001:1001:,,,:/home/git:/bin/bash
改為:
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell - 克隆倉庫到本地 git clone git@server:/路徑/test.git
最坑的時候到了:第一次會提示:
The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)?
一定要輸入yes 不能直接回車
一定要輸入yes 不能直接回車
一定要輸入yes 不能直接回車
然后輸入密碼。