Changes

From Amahi Wiki
Jump to: navigation, search
5,292 bytes added ,  02:55, 13 March 2012
Created page with "[http://git-scm.com/ Git] is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. ..."
[http://git-scm.com/ 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 [http://sourceforge.net/apps/trac/sourceforge/wiki/GitWeb%20repository%20browser Gitweb], provides a web interface for browsing your project.

== Setup==
[http://wiki.amahi.org/index.php/Open_Terminal_as_root Open a terminal as root] user and do the following:
* Install dependencies
{{Code|yum -y install git git-daemon gitweb}}
* Add user
{{Code|useradd -U -d /var/cache/git -s /usr/libexec/git-core/git-shell git}}
* Set directory permissions
{{Code|cd /var/cache
chown -R git:git git
chmod 755 git}}
* Create public SSH key storage
{{Code|cd /var/cache/git;
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
chown -R git:git .ssh/}}
* Create init script
{{Code|vi /etc/init.d/git}}
<blockquote>
{{Text|Text=#!/bin/sh
<nowiki>#</nowiki>
<nowiki>#</nowiki> Startup/shutdown script for Git Daemon
<nowiki>#</nowiki>
<nowiki>#</nowiki> Linux chkconfig stuff:
<nowiki>#</nowiki>
<nowiki>#</nowiki> chkconfig: 345 56 10
<nowiki>#</nowiki> description: Startup/shutdown script for Git Daemon
<nowiki>#</nowiki>
. /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 $RETVAL}}</blockquote>
* Set init script to run
{{Code|chmod 755 /etc/init.d/git;
chkconfig git on
service git start}}
* Create repository
{{Code|cd /var/cache/git/
mkdir test.git
cd test.git
git init --bare
chown -R git:git ../test.git/}}
* Add a short description
{{Code|cd /var/cache/git/test.git/
echo "test test repo" > description}}
* Configure user access
{{Code|vi config}}
<blockquote>
{{Text|Text=[core]
repositoryformatversion = 0
filemode = true
bare = true

[gitweb]
owner = Your Name}}</blockquote>
* Create local repository and commit
{{Code|mkdir ~/test
cd ~/test && git init
echo 'test' > README
git add README
git commit -m "initial README file"}}
* Create SSH rsa public key
{{Code|ssh-keygen -t rsa -C "admin@yourisp.com" -N amahi -f /var/cache/git/.ssh/authorized_keys}}
* Push to the repository
{{Code|git remote add origin git@git.yourisp.com:test.git
git push origin master}}
* Add to bottom of the configuration file
{{Code|vi /etc/gitweb.conf}}
<blockquote>
{{Text|Text=$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/;"}}</blockquote>
* Create custom index.html file
{{Code|cd /var/hda/web-apps/gitweb
vi html/index.html}}
<blockquote>
{{Text|Text=<!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://git/git/"></HEAD>
<BODY>
Optional page text here.
</BODY>
</HTML>}}</blockquote>
* Copy web files and set permissions
{{Code|cp -r /var/www/git/* html
chown -R apache:users html}}
* Modify the web app configuration file as follows
{{Code|vi /etc/httpd/conf.d/####-gitweb.conf}}
<blockquote>
{{Text|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

/etc/httpd/conf.d/git.conf
<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>}}</blockquote>
* Restart Apache
{{Code|/etc/init.d/httpd restart}}

==Complete==
Navigate to <nowiki>http://gitweb/git</nowiki> to browse the newly created repository.


==References==
[http://www.kutukupret.com/2010/03/26/hosting-your-own-git-repository-on-fedora-12/ Hosting your own Git Repository on Fedora 12]
12,424

edits