標籤:
1.安裝git用yum install git-core(伺服器)
2.建立裸倉庫(伺服器)
[[email protected]]$ mkdir /home/workspace[[email protected]]$ cd /home/workspace[[email protected]]$ git init -bare wwwroot.git
3.給許可權(伺服器)
chown -R git:git wwwroot.git
4.添加git使用者和密碼(伺服器)
adduser git
passwd git 123
5.禁止shell登陸如果不知道git在哪裡用:which git-shell 尋找出來填寫正確路徑(伺服器)
編輯/etc/passwd
git:x:1001:1001:,,,:/home/git:/bin/bash
改為:
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
6.用clone遠程下載git項目(用戶端)
git clone [email protected]115.28.38.789:/home/workspacewwwroot.git
IP和路徑一定要填寫正確
7.用戶端可以操作git相關操作了
git add *
git commit -m ‘add‘
git remote add origin [email protected]:/home/workspacewwwroot.git (只在第一次關聯的時候使用,第二次不需要在使用,直接push就可以了)
git push origin master
項目每次修改或添加就可以這些命令完成
8.進行git和web目錄關聯,同步瀏覽網站
設定鉤子,這樣每次運行git就可以同步提交瀏覽網站了
[[email protected]]$ cd /home/workspace/wwwroot.git/hooks[[email protected]]$ cat > post-receive <<EOF>#!/bin/bash>git --work-tree=/home/website/wwwroot checkout -f >EOF[[email protected]]$ chmod +x post-receive
分布式伺服器,每一個電腦都可以作為git伺服器,每個電腦都是一個節點!祝君好運!
Linux的centos搭建git伺服器