日期:2014-05-17  浏览次数:20815 次

使用apache 配置http协议的git库
使用apache 配置http协议的git库.

在/home/git/目录下创建gitrepo目录,
在gitrepo中创建test.git
进入test.git目录
执行
git init --bare?
mv hooks/post-update.sample hooks/post-update
./hooks/post-update

apache配置文件部分,git.conf

DavLockDB "/usr/local/apache/var/DavLock"

Alias /git "/home/git/gitrepo"

<Directory "/home/git/gitrepo/">
    Dav On
    Options +Indexes +FollowSymLinks

    Deny from all

    AuthType Basic
    AuthName "Git"
    AuthUserFile "/home/git/gitrepo/user.git"
    AuthGroupFile "/home/git/gitrepo/group.git"
    Require valid-user
</Directory>

<Directory "/home/git/gitrepo/test.git/">
    Allow from all
    Order Allow,Deny
    
    <Limit GET>
       Require group testproject-read
    </Limit>
    
    <Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
       Require group testproject-write
    </Limit>
</Directory>

<Location /git>
    SetHandler None
</Location>
?
user.git 采用htpasswd生成
group.git内容如下:
testproject-read: jack
testproject-write: john alex
?

添加本地授权文件,避免每次都提示输入密码:
Win: 添加环境变量HOME=c:/user/jack
在该目录下创建文件_netrc,内容如下
machine www.gitserver.com
login jack
password 123456

?*unix:在~/目录添加.netrc,内容同上。