在Ubuntu 14.04上配置 gitweb

1。先安装 gitweb和 apache2

2. 修改配置文件(因为gitweb在/etc/apache2/conf.d/下安装了配置文件,这个目录是过时的):

sudo cp /etc/apache2/conf.d/gitweb /etc/apache2/conf-available/gitweb.conf
cd /etc/apache2/conf-enabled
sudo ln -s ../conf-available/gitweb.conf

修改gitweb.conf 如下:

Alias /gitweb /usr/share/gitweb

<Directory /usr/share/gitweb>
  Options +FollowSymLinks +ExecCGI
  AddHandler cgi-script .cgi
</Directory>
(在 FollowSymLinks之前加上了 "+"解决语法问题)

3. 使能cgi:

sudo a2enmod cgi
sudo service apache2 restart

4. 修改/etc/gitweb.conf,添加上项目信息:

$projectroot = "/home/charles/repo";
$projects_list = $projectroot;

5. 创建项目信息.

把项目信息和实际代码分开。

 mkdir repo
 cd repo/
 git clone  --bare ~/code/linux-3.10.28 linux-3.10.28

然后,打开 http://localhost/gitweb/linux-3.10.28, 就能看到项目信息了。

6。因为 gitweb 的数据来源和实际的代码不在同一个地方,所以,需要经常更新 ~/repo。

这可以用一个脚本来实现:

#!/bin/bash
cd ${HOME}/code/linux-3.10.28
git remote add web  /home/charles/repo/linux-3.10.28 >& /dev/null 
sudo git push -f web
如果有下面的警告,

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

执行 
  git config --global push.default matching

就行了。

可以自动化的来更新:

crontab -l
* * * * * ${HOME}/foo/git.web.push

参考资料:

1. Install git/gitolite/gitweb on Ubuntu 14.04

2. Setting up Gitweb on your Ubuntu workstation

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值