How To: Install and Configure GitWeb

2023-10-30 05:38
文章标签 install configure gitweb

本文主要是介绍How To: Install and Configure GitWeb,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

http://gofedora.com/how-to-install-configure-gitweb/

Goal

Setting up gitweb (web interface for SCM software git) for your project’s git repository for public access and developer commits via ssh.

Assumptions
  1. You already have your project’s git repository.
  2. You have hosting space somewhere to host gitweb.
  3. You have root access.
  4. You are using Apache as webserver.
Example for this howto

Project : VideoCache
Domain for gitweb : git.cachevideos.com
URL for git access for videocache : http://git.cachevideos.com/videocache.git
Actual path on server : /home/saini/domains/cachevideos.com/git
Git repository : /home/saini/projects/videocache/

Installation

Installation is pretty easy. Just one single command would do everything.

[
root@
localhost ~]
# yum install gitweb (do as root)

This will create a directory /var/www/git which is default for gitweb.

Copy the directory /var/www/git/ to /home/saini/domains/cachevideos.com/git

[
root@
localhost ~]
# cp -r /var/www/git /home/saini/domains/cachevideos.com/git
Configuration

1. GitWeb

Open the file /etc/gitweb.conf (it may or may not be there) and add the following lines to it.

# Change This

$projectroot = '/home/saini/domains/cachevideos.com/git' ;
# Change This
$site_name = "Kulbir Saini's git trees." ;
# Don't Change the variables below
$my_uri = "/" ;
$home_link = '/' ;
@stylesheets = ( "/gitweb.css" ) ;
$favicon = "/git-favicon.png" ;
$logo = "/git-logo.png" ;

2. Apache

Open the file /etc/httpd/conf.d/git.conf and clear all the lines that are already there and add the following lines to it

  DocumentRoot /
home/
saini/
domains/
cachevideos.com/
git
ServerName git.cachevideos.com
ErrorLog "/home/saini/domains/cachevideos.com/logs/error_log"
CustomLog "/home/saini/domains/cachevideos.com/logs/access_log" combined
SetEnv GITWEB_CONFIG / etc/ gitweb.conf
DirectoryIndex gitweb.cgi

Allow from all
AllowOverride all
Order allow,deny
Options +ExecCGI
AddHandler cgi-script .cgi

SetHandler cgi-script

RewriteEngine on
RewriteRule ^[ a-zA-Z0-9 _/-] +/.git/ ?( /?.* ) ?$ / gitweb.cgi% { REQUEST_URI} [ L,PT]

3. Git repository configuration

Go to your git repository (/home/saini/projects/videocache/ ) and make the following changes.

(a). Open file .git/description and add a short nice description for your project.

videocache is a squid url rewriter plugin written in Python to facilitate youtube, metacafe, dailymotion, google, vimeo, msn soapbox, tvuol.uol.com.br, blip.tv, break.com videos and wrzuta.pl audio caching.

(b). Open file .git/config and append the following lines

[
gitweb]

owner = "Kulbir Saini"

Copy project’s git repository for gitweb

Copy the /home/saini/projects/videocache/.git directory to /home/saini/domains/cachevideos.com/git/videocache.git

[
root@
localhost ~]
# cp -r /home/saini/projects/videocache/.git /home/saini/domains/cachevideos.com/git/videocache.git
Finishing Step

Restart Apache webserver.

[
root@
localhost ~]
# service httpd restart

Now you can browser a list of your projects’ git repositories at http://git.cachevideos.com/ .

Adding another project repository

Just copy the project repository’s .git directory to /home/saini/domains/cachevideos.com/git/prjoect_name.git . And it’ll be shown on the list.

Committing (pushing) to the repository

For committing to the repository via ssh use the following command.

# Pushing everything (Please see the username)

[ root@ localhost videocache] # git push --all ssh://saini@git.cachevideos.com/~saini/domains/cachevideos.com/git/videocache.git

To update tags on the remote repository use this command.

# Pushing all tags

[ root@ localhost videocache] # git push --tags ssh://saini@git.cachevideos.com/~saini/domains/cachevideos.com/git/videocache.git

Well, if you consider just the web interface and committing part for your project, thats all. But things can be fine tuned further. Below are few hacks!

1. Enabling nice urls.

By default the urls for browsing repository via git web are pretty crappy and difficult to remember. The RewriteRule and RewriteEngine lines in your Apache configuration file (/etc/httpd/conf.d/git.conf ) takes care of that and produce nice and clean urls.

So you can browser the repository via http://git.cachevideos.com/videocache.git instead of http://git.cachevideos.com/?p=videocache.git;a=summary .

2. Enabling remote ls (git-ls-remote or git ls-remote)

This is the most trickiest part. If you try the command below, it won’t produce any output

[
root@
localhost ~]
# git-ls-remote http://git.cachevideos.com/videocache.git

You need to go to project’s repository in gitweb and then run the following command to update the server info for git.

[
root@
localhost ~]
# cd /home/saini/domains/cachevideos.com/git/videocache.git/

[ root@ localhost ~] # git-update-server-info

Try the ls-remote command now and it should succeed by producing all the branches and tags in the remote repository.

But there is a problem, you have to run the above command after every commit to the remote repository. To solve this issue, you can enable post-update hook for the project’s repository in gitweb. Use the following command to enable it.

[
root@
localhost ~]
# cd /home/saini/domains/cachevideos.com/git/videocache.git/

[ root@ localhost ~] # chmod +x post-update

The above command will update the server info automatically every time you commit.

Thats all you need to do for setting up gitweb. I hope this will be helpful.

这篇关于How To: Install and Configure GitWeb的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/305922

相关文章

收藏:解决 pip install 出现 error: subprocess-exited-with-error 错误的方法

在使用 pip 安装 Python 包时,有时候会遇到 error: subprocess-exited-with-error 错误。这种错误通常是由于 setuptools 版本问题引起的。本文将介绍如何解决这一问题 当你使用 pip install 安装某个 Python 包时,如果 setuptools 版本过高或过低,可能会导致安装过程出错,并出现类似以下错误信息:error: subpr

[轻笔记] pip install : Read timed out. (closed)

添加超时参数(单位秒) pip --default-timeout=10000 install ${package_name}

Ubuntu下搭建基于apache2的gerrit+gitweb服务器

说明:Ubuntu版本12.04   1. 配置gerrit管理帐号 1 sudo adduser gerrit   增加sudo权限: 1 sudo usermod -a -G sudo gerrit   切换到gerrit账号: 1 sudo su gerrit     2. 安装java 1 2

pip install pyaudio sounddevice error: externally-managed-environment

shgbitai@shgbitai-C9X299-PGF:~/pythonworkspace/ai-accompany$ pip install pyaudio sounddeviceerror: externally-managed-environment× This environment is externally managed╰─> To install Python package

maven 指令之package 和install的区别

https://blog.csdn.net/zy103118/article/details/79901357   maven 指令之package 和install的区别 2018年04月11日 19:08:46 brave_zhao 阅读数:2018更多 个人分类: maven maven package 和 install 区别 原创 2016年08月18日 14:55:26

安装Python(install python),安装pip(install pip)

海南副教授陈晶优下台 ,shut down        you are rubbish ,you need study. How to install python environment and pip?   Step 1:Download https://www.python.org/download

【解决bug之路】npm install node-sass(^4.14.1)连环报错解决!!!(Windows)

有关node-sass的深入分析可参考:又报gyp ERR!为什么有那么多人被node-sass 坑过? 主要有如下三方面错误,请自查: 1.node,npm版本需与node-sass版本匹配,像node-sass(^4.14.1)就得node 14.x版本才可以,node 16不行 gyp ERR! build error15 gyp ERR! stack Error: `

[INSTALL] MSYS2 -- Windows下的类Linux环境

一、安装 1. 从https://www.msys2.org/ 下载安装msys2 也可以从镜像: http://mirrors.aliyun.com/msys2/distrib/x86_64/ 下载最新的安装包 msys2-x86_64-20230718.exe 2. 更新下载源为阿里云 sed -i "s#https\?://mirror.msys2.org/#http://mirrors

pod install 报错处理

由于墙的原因,pod install 、 pod update经常报错 有效的解决方案(推荐): 以SnapKit为例 找不报错的同事要以下两个文件(指定的版本) 1. /Users/xxx/Library/Caches/CocoaPods/Pods/Release/SnapKit 2. /Users/xxx/Library/Caches/CocoaPods/Pods/Specs

【HarmonyOS】安装包报错,code:9568282 error: install releaseType target not same.

【HarmonyOS】安装包报错,code:9568282 error: install releaseType target not same. 报错信息 Install Failed: error: failed to install bundle. code:9568282 error: install releaseType target not same. You can also