Git and Gitweb
| Update Needed | |
|---|---|
| The contents of this page have become outdated or irrelevant. Please consider updating it. |
NOTE: There is a one-click app currently in ALPHA being tested.
Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do. Coupled with Gitweb, provides a web interface for browsing your project.
This tutorial will show you how to install, create a repo, and browse that repo on your HDA.
NOTE: Tested on Fedora 14.
Contents
Setup
- Create web app (Advanced Settings must be enabled on HDA)
- From the Dashboard main page, select Apps at the top.
- Choose Webapps
- Select New Web App button at the bottom
- Enter gitweb for the Name (ensure the path reflects the name correctly)
- Choose Create
- Open a terminal as root user and do the following:
- Install dependencies
yum -y install git git-daemon gitweb
- Look for the ####-gitweb.conf in /etc/httpd/conf.d (#### is some number, i.e. 1000) file and open it in your favorite editor. Add text after ServerAlias line
Text=Alias /git /var/hda/web-apps/gitweb/html RewriteEngine On RewriteRule ^git$ git/ [R] DirectoryIndex gitweb.cgi SetEnv GITWEB_CONFIG "/etc/gitweb.conf" AddHandler cgi-script .cgi
- Create web page to browse repository
cd /var/hda/web-apps/gitweb echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Your Page Title</title> <meta http-equiv="REFRESH" content="0;url=http://gitweb/git/"></HEAD> <BODY> Optional page text here. </BODY> </HTML>' > html/index.html chown apache.users html/index.html
useradd -U -d /var/cache/git -s /usr/libexec/git-core/git-shell git
cd /var/cache chown -R git:git git chmod 755 git/
#!/bin/sh
#
# Startup/shutdown script for Git Daemon
#
# Linux chkconfig stuff:
#
# chkconfig: 345 56 10
# description: Startup/shutdown script for Git Daemon
#
. /etc/init.d/functions
DAEMON=/usr/libexec/git-core/git-daemon
ARGS='--base-path=/var/cache/git --detach --syslog --export-all --user=git --group=git'
prog=git-daemon
start () {
echo -n $"Starting $prog: "
# start daemon
daemon $DAEMON $ARGS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/git-daemon
return $RETVAL
}
stop () {
# stop daemon
echo -n $"Stopping $prog: "
killproc $DAEMON
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/git-daemon
}
restart() {
stop
start
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status $DAEMON
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 3
esac
exit $RETVALchmod 755 /etc/init.d/git; /etc/init.d/git start /sbin/chkconfig git on
git config --global user.name "MyHDA" git config --global user.email myhda@localhost
cd /var/cache/git/ git init test cd test
echo 'test' > README git add README git commit -a -m "initial README file"
cd /var/cache/git/ git clone test test.git cd test.git git push origin master
[gitweb]
owner = MyHDA$feature{'blame'}{'default'} = [undef];
$feature{'pickaxe'}{'default'} = [undef];
$feature{'search'}{'default'} = [undef];
$feature{'grep'}{'default'} = 1;
$feature{'snapshot'}{'default'} = ['tgz', 'gzip', 'zip'];
$feature{'snapshot'}{'override'} = 1;
$site_name = "HDA Git";
$projectroot = '/var/cache/git/';
$projects_list_description_width = 50;
$git_temp = "/tmp";
$home_text = "indextext.html";
$site_footer = "indexfooter.html";
$projects_list = $projectroot;
$home_link_str = "http://gitweb / git ";
$stylesheet = "/git/static/gitweb.css";
$logo = "/git/static/git-logo.png";
$favicon = "/git/static/git-favicon.png";
$feature{'pathinfo'}{'default'} = [1];
$my_uri = "http://gitweb/git/";
$home_link = "http://gitweb/git/;"d /var/hda/web-apps/gitweb cp -r /var/www/git/* html chown -R apache:users html/
cd /var/cache/git sed -i '1d' test.git/.git/description echo 'Test Repo' >> test.git/.git/description
<Directory /var/hda/web-apps/gitweb/html>
RewriteEngine On
RewriteBase /git/
RewriteRule ^$ gitweb.cgi [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) gitweb.cgi/$1 [QSA,L]
</Directory>chown -R git.git /var/cache/git rm -rf /var/cache/git/test /etc/init.d/httpd restart
Complete
That is it. Navigate to http://gitweb/git to browse the newly created repository.
Optional
You can add the Amahi repo by doing the following:
cd /var/cache/git git clone git://git.amahi.org/amahi.git
