啊 大周末的 來(lái)加班? 活都讓小伙子們干了? 正好有新項(xiàng)目 之前代碼部署全部用svn的hooks實(shí)現(xiàn)的 一直想轉(zhuǎn)成git? 今天研究研究
yum install git git-daemon
useradd git
chown -R git:git /home/git
su git
cd ~
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
禁止git用戶(hù)shell登錄
sudo vim /etc/passwd
查找passwd的git那行邢羔,可以看到下面類(lèi)似的文本:
git:x:1000:1000::/home/git:/bin/sh
我們把shell換一下懈费,改成git-shell:
git:x:1000:1000::/home/git:/usr/bin/git-shell
如果我們想換成git登陸躯畴,會(huì)提示下面的信息:
su git
fatal: What do you think I am? A shell?
cd
mkdir anhaocom.git
cd anhaocom.git/
git --bare init
vi /home/git/anhaocom.git/hooks/post-receive
添加上
#!/bin/sh
#GIT_WORK_TREE=/Data/webapps/anhaocom git checkout prod -f
git --work-tree=/Data/webapps/anhaocom --git-dir=/home/git/anhaocom.git checkout -f
參考文檔
http://zoomq.qiniudn.com/ZQScrapBook/ZqFLOSS/data/20130730120622/index.html
http://git-scm.com/book/zh/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git
http://icyleaf.com/2012/03/apps-auto-deploy-with-git/
https://coderwall.com/p/xczkaq
http://happycasts.net/episodes?tag_id=2
http://yuguo.us/weblog/git-feature/