Difference between revisions of "Git and Gitweb"
From Amahi Wiki
(→Setup) |
(→Setup) |
||
Line 47: | Line 47: | ||
</BODY> | </BODY> | ||
</HTML>' > html/index.html | </HTML>' > html/index.html | ||
− | chown apache.users html/index.html}} | + | chown apache.users html/index.html}}</li> |
</ol> | </ol> | ||
− | + | <li>Install dependencies | |
− | {{Code|yum -y install git git-daemon gitweb}} | + | {{Code|yum -y install git git-daemon gitweb}}</li> |
− | + | <li>Add user | |
− | {{Code|useradd -U -d /var/cache/git -s /usr/libexec/git-core/git-shell git}} | + | {{Code|useradd -U -d /var/cache/git -s /usr/libexec/git-core/git-shell git}}</li> |
− | + | <li>Set directory permissions | |
{{Code|cd /var/cache | {{Code|cd /var/cache | ||
chown -R git:git git | chown -R git:git git | ||
− | chmod 755 git}} | + | chmod 755 git}}</li> |
− | + | <li>Create public SSH key storage | |
{{Code|cd /var/cache/git; | {{Code|cd /var/cache/git; | ||
mkdir .ssh | mkdir .ssh | ||
Line 63: | Line 63: | ||
touch .ssh/authorized_keys | touch .ssh/authorized_keys | ||
chmod 600 .ssh/authorized_keys | chmod 600 .ssh/authorized_keys | ||
− | chown -R git:git .ssh/}} | + | chown -R git:git .ssh/}}</li> |
− | + | <li>Create init script | |
{{Code|vi /etc/init.d/git}} | {{Code|vi /etc/init.d/git}} | ||
− | + | ||
{{Text|Text=#!/bin/sh | {{Text|Text=#!/bin/sh | ||
<nowiki>#</nowiki> | <nowiki>#</nowiki> | ||
Line 128: | Line 128: | ||
esac | esac | ||
− | exit $RETVAL}}</ | + | exit $RETVAL}}</li> |
− | + | <li>Set init script to run | |
{{Code|chmod 755 /etc/init.d/git; | {{Code|chmod 755 /etc/init.d/git; | ||
chkconfig git on | chkconfig git on | ||
− | service git start}} | + | service git start}}</li> |
− | + | <li>Create repository | |
{{Code|cd /var/cache/git/ | {{Code|cd /var/cache/git/ | ||
mkdir test.git | mkdir test.git | ||
cd test.git | cd test.git | ||
git init --bare | git init --bare | ||
− | chown -R git:git ../test.git/}} | + | chown -R git:git ../test.git/}}</li> |
− | + | <li>Add a short description | |
{{Code|cd /var/cache/git/test.git/ | {{Code|cd /var/cache/git/test.git/ | ||
− | echo "test test repo" > description}} | + | echo "test test repo" > description}}</li> |
− | + | <li>Configure user access | |
{{Code|vi config}} | {{Code|vi config}} | ||
− | + | ||
{{Text|Text=[core] | {{Text|Text=[core] | ||
repositoryformatversion = 0 | repositoryformatversion = 0 | ||
Line 151: | Line 151: | ||
[gitweb] | [gitweb] | ||
− | owner = Your Name}}</ | + | owner = Your Name}}</li> |
− | + | <li>Create local repository and commit | |
{{Code|mkdir ~/test | {{Code|mkdir ~/test | ||
cd ~/test && git init | cd ~/test && git init | ||
echo 'test' > README | echo 'test' > README | ||
git add README | git add README | ||
− | git commit -m "initial README file"}} | + | git commit -m "initial README file"}}</li> |
− | + | <li>Create SSH rsa public key | |
− | {{Code|ssh-keygen -t rsa -C "admin@yourisp.com" -N amahi -f /var/cache/git/.ssh/authorized_keys}} | + | {{Code|ssh-keygen -t rsa -C "admin@yourisp.com" -N amahi -f /var/cache/git/.ssh/authorized_keys}}</li> |
− | + | <li>Push to the repository | |
{{Code|git remote add origin git@git.yourisp.com:test.git | {{Code|git remote add origin git@git.yourisp.com:test.git | ||
− | git push origin master}} | + | git push origin master}}</li> |
− | + | <li>Add to bottom of the configuration file | |
{{Code|vi /etc/gitweb.conf}} | {{Code|vi /etc/gitweb.conf}} | ||
− | + | ||
{{Text|Text=$feature{'blame'}{'default'} = [undef]; | {{Text|Text=$feature{'blame'}{'default'} = [undef]; | ||
$feature{'pickaxe'}{'default'} = [undef]; | $feature{'pickaxe'}{'default'} = [undef]; | ||
Line 185: | Line 185: | ||
$feature{'pathinfo'}{'default'} = [1]; | $feature{'pathinfo'}{'default'} = [1]; | ||
$my_uri = "http://gitweb/git/"; | $my_uri = "http://gitweb/git/"; | ||
− | $home_link = "http://gitweb/git/;"}}</ | + | $home_link = "http://gitweb/git/;"}}</li> |
− | + | <li>Copy web files and set permissions | |
{{Code|cp -r /var/www/git/* html | {{Code|cp -r /var/www/git/* html | ||
− | chown -R apache:users html}} | + | chown -R apache:users html}}</li> |
+ | </ul> | ||
==Complete== | ==Complete== |
Revision as of 11:58, 13 March 2012
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.
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:
bash code cd /etc/httpd/conf.d
- Look for the ####-gitweb.conf (#### is some number, i.e. 1000) file and open it in your favorite editor. Remove the text between ServerAlias and the last two lines, then add the following
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>
- Restart web server to enable the changes
bash code /etc/init.d/httpd restart;
- Create web page to browse repository
- Install dependencies
bash code yum -y install git git-daemon gitweb
- Add user
bash code useradd -U -d /var/cache/git -s /usr/libexec/git-core/git-shell git
- Set directory permissions
bash code cd /var/cache chown -R git:git git chmod 755 git
- Create public SSH key storage
bash 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
bash code vi /etc/init.d/git
Text #!/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
- Set init script to run
bash code chmod 755 /etc/init.d/git; chkconfig git on service git start
- Create repository
bash code cd /var/cache/git/ mkdir test.git cd test.git git init --bare chown -R git:git ../test.git/
- Add a short description
bash code cd /var/cache/git/test.git/ echo "test test repo" > description
- Configure user access
bash code vi config
Text [core] repositoryformatversion = 0 filemode = true bare = true [gitweb] owner = Your Name
- Create local repository and commit
bash code mkdir ~/test cd ~/test && git init echo 'test' > README git add README git commit -m "initial README file"
- Create SSH rsa public key
bash code ssh-keygen -t rsa -C "admin@yourisp.com" -N amahi -f /var/cache/git/.ssh/authorized_keys
- Push to the repository
bash code git remote add origin git@git.yourisp.com:test.git git push origin master
- Add to bottom of the configuration file
bash code vi /etc/gitweb.conf
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/;"
- Copy web files and set permissions
bash code cp -r /var/www/git/* html chown -R apache:users html
bash code |
---|
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://git/git/"></HEAD> <BODY> Optional page text here. </BODY> </HTML>' > html/index.html chown apache.users html/index.html
|
Complete
Navigate to http://gitweb/git to browse the newly created repository.