特殊:Badtitle/NS100:Git:修订间差异
小 创建新页面为 '{{From|https://help.ubuntu.com/community/Git}} {{Languages|UbuntuHelp:Git}} == Introduction == [http://git-scm.com/ Git] is an open source, distributed version control system d...' |
小无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第5行: | 第5行: | ||
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. | 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. | ||
== Installation == | == Installation == | ||
Following these instructions we assume you already have a Ubuntu | Following these instructions we assume you already have a Ubuntu 9.04 installed on you computer/server and that you already have a public ssh key on your machine you can use that to initialize the repository (Don't have one, [[UbuntuHelp:SSHHowto#Tip:_Generating_Public_Keys|look here]]). The following instructions will guide you on how to set up and run a fully managed hosting for projects using git on your server. | ||
=== Used software === | === Used software === | ||
This tutorial was done using | This tutorial was done using an Ubuntu 9.04 (Jaunty Jackalope). | ||
We'll be using the latest [http://git-scm.com/ git] package available in the | We'll be using the latest [http://git-scm.com/ git] package available in the archive. | ||
For git project management will be using [http://eagain.net/gitweb/?p=gitosis.git Gitosis]. | |||
For git project management will be using [http:// | |||
For repository web browsing we will be using [http://viewgit.sourceforge.net/ ViewGit]. The latest version we will clone directly from a git repository: | For repository web browsing we will be using [http://viewgit.sourceforge.net/ ViewGit]. The latest version we will clone directly from a git repository: | ||
git clone git://repo.or.cz/viewgit.git | git clone git://repo.or.cz/viewgit.git | ||
=== Setting up Git and Project Management === | === Setting up Git and Project Management === | ||
Use your favorite package installer to install git-core | Use your favorite package installer to install git-core and gitosis packages: | ||
<pre><nowiki> | <pre><nowiki> | ||
apt-get install git-core | apt-get -y install git-core gitosis | ||
</nowiki></pre> | </nowiki></pre> | ||
Now that you should have both packages installed, we can set up gitosis. | Now that you should have both packages installed, we can set up gitosis. | ||
First copy your public key to the server: | First copy your public key to the server: | ||
<pre><nowiki> | <pre><nowiki> | ||
scp .ssh/ | scp .ssh/id_rsa.pub username@yourserver.com:/tmp | ||
</nowiki></pre> | </nowiki></pre> | ||
Initialize gitosis using your copied key: | Initialize gitosis using your copied key: | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo -H -u | sudo -H -u gitosis gitosis-init < /tmp/id_rsa.pub | ||
</nowiki></pre> | </nowiki></pre> | ||
Once you saw some output like this: `Initialized empty Git repository in ./` | Once you saw some output like this: `Initialized empty Git repository in ./` | ||
Your gitosis is installed. You can now remove the copied key. | Your gitosis is installed. You can now remove the copied key. | ||
<pre><nowiki> | <pre><nowiki> | ||
rm /tmp/ | rm /tmp/id_rsa.pub | ||
</nowiki></pre> | </nowiki></pre> | ||
Once done, you can now checkout the gitosis-admin branch on your local machine: | Once done, you can now checkout the gitosis-admin branch on your local machine: | ||
<pre><nowiki> | <pre><nowiki> | ||
git clone | git clone gitosis@yourserver.com:gitosis-admin.git | ||
</nowiki></pre> | |||
Note: If the cloning doesn't work, maybe you have "PermitRootLogin no" in the SSH Server and you need to add gitosis user to it. | |||
<pre><nowiki> | |||
sudo vim /etc/ssh/sshd_config | |||
AllowUsers gitosis | |||
</nowiki></pre> | </nowiki></pre> | ||
Use your favorite editor to modify the contents of the gitosis configuration file: | Use your favorite editor to modify the contents of the gitosis configuration file: | ||
第56行: | 第52行: | ||
[group team] | [group team] | ||
writable = testproject | writable = testproject | ||
members = hostname. | members = hostname.yourserver.com | ||
[group gitosis-admin] | [group gitosis-admin] | ||
第62行: | 第58行: | ||
members = keyfilename | members = keyfilename | ||
</nowiki></pre> | </nowiki></pre> | ||
`hostname. | `hostname.yourserver.com` or `keyfilename` is the name of the public key without `.pub` extension you copied into `gitosis-admin/keydir/` directory. | ||
After you've done editing, save the file, and commit it back to the server. | After you've done editing, save the file, and commit it back to the server. | ||
<pre><nowiki> | <pre><nowiki> | ||
第72行: | 第68行: | ||
To commit the project you just created, initiate a new git project, add files to it, commit it, then push it to your repository with the name you set up in gitosis config file. | To commit the project you just created, initiate a new git project, add files to it, commit it, then push it to your repository with the name you set up in gitosis config file. | ||
<pre><nowiki> | <pre><nowiki> | ||
mkdir testproject | |||
cd testproject | |||
git init | git init | ||
touch a_text_file.txt | touch a_text_file.txt | ||
git add . | git add . | ||
git commit -m " | git commit -a -m "Initial import" | ||
git remote add origin gitosis@ | git remote add origin gitosis@yourserver.com:testproject.git | ||
git push | git push origin master | ||
</nowiki></pre> | </nowiki></pre> | ||
The project should be committed! | The project should be committed! | ||
{i} If not, please check your `/srv/gitosis/.ssh/authorized_keys` file, if that one contains your correct public key! | {i} If not, please check your `/srv/gitosis/.ssh/authorized_keys` file, if that one contains your correct public key! | ||
==== Adding users ==== | |||
First, gather their public SSH keys, which I'll call "kakashi.pub" and "naruto.pub", and drop them into keydir/ of your local gitosis-admin repository. Second, edit gitosis.conf and add them to the "members" list. | |||
<pre><nowiki> | |||
cd gitosis-admin | |||
cp ~/kakashi.pub keydir/ | |||
cp ~/naruto.pub keydir/ | |||
git add keydir/kakashi.pub keydir/naruto.pub | |||
</nowiki></pre> | |||
Note that the key filename must have a ".pub" extension. | |||
gitosis.conf changes: | |||
<pre><nowiki> | |||
[group team] | |||
writable = testproject | |||
- members = hostname.yourserver.com | |||
+ members = hostname.yourserver.com kakashi naruto | |||
</nowiki></pre> | |||
Commit and push: | |||
<pre><nowiki> | |||
git commit -a -m "Granted Kakashi and Naruto commit rights to testproject" | |||
git push | |||
</nowiki></pre> | |||
That's it. Kakashi and Naruto can now clone the testproject repository like so: | |||
<pre><nowiki> | |||
git clone [email protected]:testproject.git | |||
</nowiki></pre> | |||
Kakashi and Naruto will also have commit rights. | |||
== The web browsing interface == | == The web browsing interface == | ||
Server will need a web server so I recommend you to install [[UbuntuHelp:Apache|Apache]] with support for php. Once ViewGit can be linked to [[UbuntuHelp:GeSHI|GeSHI]], I also recommend you installing the `php-geshi` package: | Server will need a web server so I recommend you to install [[UbuntuHelp:Apache|Apache]] with support for php. Once ViewGit can be linked to [[UbuntuHelp:GeSHI|GeSHI]], I also recommend you installing the `php-geshi` package: | ||
第120行: | 第144行: | ||
$conf['datetime_full'] = '%Y-%m-%d %H:%M:%S'; | $conf['datetime_full'] = '%Y-%m-%d %H:%M:%S'; | ||
// Maximum length of commit message's first line to show | // Maximum length of commit message's first line to show | ||
$conf['commit_message_maxlen'] = 50; | $conf['commit_message_maxlen'] = 50; | ||
第169行: | 第193行: | ||
$conf['ad'] = false; | $conf['ad'] = false; | ||
</nowiki></pre> | </nowiki></pre> | ||
Now you should be able to browse your Git repository by going to http://localhost/viewgit/ | Now you should be able to browse your Git repository by going to http://localhost/viewgit/ if you got problems on accessing repositories, add your web server user to the same group gitosis user is: | ||
<pre><nowiki> | |||
adduser www-data git | |||
</nowiki></pre> | |||
=== Making available public cloning of the projects === | === Making available public cloning of the projects === | ||
To make available public access for cloning of the projects, you have to set up git-daemon. git-daemon is a service which runs on port `9418` and handles public requests for project cloning. git-daemon comes together with git-core so no additional installation is required. | To make available public access for cloning of the projects, you have to set up git-daemon. git-daemon is a service which runs on port `9418` and handles public requests for project cloning. git-daemon comes together with git-core so no additional installation is required. | ||
To make this service easier to administrate, here is an init script to start and stop the daemon: | To make this service easier to administrate, here is an init script to start and stop the daemon. | ||
It is, however, easier to make git a subservice of [[UbuntuHelp:xinetd|xinetd]], by editing <tt>/etc/xinetd.d/git</tt> and changing <tt>disable=no</tt> to <tt>disable=yes</tt>. | |||
<pre><nowiki> | <pre><nowiki> | ||
#!/bin/sh | #! /bin/sh | ||
# Taken from here: http://pastie.org/227647 | |||
. /lib/ | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | ||
NAME=git-daemon | |||
PIDFILE=/var/run/$NAME.pid | |||
DESC="the git daemon" | |||
DAEMON=/usr/lib/git-core/git-daemon | |||
DAEMON_OPTS="--base-path=/srv/gitosis/repositories --export-all --verbose --syslog --detach --pid-file=$PIDFILE --user=gitosis --group=nogroup" | |||
test -x $DAEMON || exit 0 | |||
[ -r /etc/default/git-daemon ] && . /etc/default/git-daemon | |||
. /lib/lsb/init-functions | |||
start_git() { | |||
start-stop-daemon --start --quiet --pidfile $PIDFILE \ | |||
stop | --startas $DAEMON -- $DAEMON_OPTS | ||
} | |||
stop_git() { | |||
start-stop-daemon --stop --quiet --pidfile $PIDFILE | |||
rm -f $PIDFILE | |||
} | |||
status_git() { | |||
start-stop-daemon --stop --test --quiet --pidfile $PIDFILE >/dev/null 2>&1 | |||
*) | } | ||
case "$1" in | |||
start) | |||
log_begin_msg "Starting $DESC" | |||
start_git | |||
log_end_msg 0 | |||
;; | |||
stop) | |||
log_begin_msg "Stopping $DESC" | |||
stop_git | |||
log_end_msg 0 | |||
;; | |||
status) | |||
log_begin_msg "Testing $DESC: " | |||
if status_git | |||
then | |||
log_success_msg "Running" | |||
exit 0 | |||
else | |||
log_failure_msg "Not running" | |||
exit 1 | |||
fi | |||
;; | |||
restart|force-reload) | |||
log_begin_msg "Restarting $DESC" | |||
stop_git | |||
sleep 1 | |||
start_git | |||
log_end_msg 0 | |||
;; | |||
*) | |||
echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 | |||
exit 1 | |||
;; | |||
esac | esac | ||
exit 0 | exit 0 | ||
</nowiki></pre> | </nowiki></pre> |
2010年5月19日 (三) 22:29的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/Git }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/af | • {{#if: UbuntuHelp:Git|Afrikaans| [[::Git/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/ar | • {{#if: UbuntuHelp:Git|العربية| [[::Git/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/az | • {{#if: UbuntuHelp:Git|azərbaycanca| [[::Git/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/bcc | • {{#if: UbuntuHelp:Git|جهلسری بلوچی| [[::Git/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/bg | • {{#if: UbuntuHelp:Git|български| [[::Git/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/br | • {{#if: UbuntuHelp:Git|brezhoneg| [[::Git/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/ca | • {{#if: UbuntuHelp:Git|català| [[::Git/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/cs | • {{#if: UbuntuHelp:Git|čeština| [[::Git/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/de | • {{#if: UbuntuHelp:Git|Deutsch| [[::Git/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/el | • {{#if: UbuntuHelp:Git|Ελληνικά| [[::Git/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/es | • {{#if: UbuntuHelp:Git|español| [[::Git/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/fa | • {{#if: UbuntuHelp:Git|فارسی| [[::Git/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/fi | • {{#if: UbuntuHelp:Git|suomi| [[::Git/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/fr | • {{#if: UbuntuHelp:Git|français| [[::Git/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/gu | • {{#if: UbuntuHelp:Git|ગુજરાતી| [[::Git/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/he | • {{#if: UbuntuHelp:Git|עברית| [[::Git/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/hu | • {{#if: UbuntuHelp:Git|magyar| [[::Git/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/id | • {{#if: UbuntuHelp:Git|Bahasa Indonesia| [[::Git/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/it | • {{#if: UbuntuHelp:Git|italiano| [[::Git/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/ja | • {{#if: UbuntuHelp:Git|日本語| [[::Git/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/ko | • {{#if: UbuntuHelp:Git|한국어| [[::Git/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/ksh | • {{#if: UbuntuHelp:Git|Ripoarisch| [[::Git/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/mr | • {{#if: UbuntuHelp:Git|मराठी| [[::Git/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/ms | • {{#if: UbuntuHelp:Git|Bahasa Melayu| [[::Git/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/nl | • {{#if: UbuntuHelp:Git|Nederlands| [[::Git/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/no | • {{#if: UbuntuHelp:Git|norsk| [[::Git/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/oc | • {{#if: UbuntuHelp:Git|occitan| [[::Git/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/pl | • {{#if: UbuntuHelp:Git|polski| [[::Git/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/pt | • {{#if: UbuntuHelp:Git|português| [[::Git/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/ro | • {{#if: UbuntuHelp:Git|română| [[::Git/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/ru | • {{#if: UbuntuHelp:Git|русский| [[::Git/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/si | • {{#if: UbuntuHelp:Git|සිංහල| [[::Git/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/sq | • {{#if: UbuntuHelp:Git|shqip| [[::Git/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/sr | • {{#if: UbuntuHelp:Git|српски / srpski| [[::Git/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/sv | • {{#if: UbuntuHelp:Git|svenska| [[::Git/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/th | • {{#if: UbuntuHelp:Git|ไทย| [[::Git/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/tr | • {{#if: UbuntuHelp:Git|Türkçe| [[::Git/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/vi | • {{#if: UbuntuHelp:Git|Tiếng Việt| [[::Git/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/yue | • {{#if: UbuntuHelp:Git|粵語| [[::Git/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/zh | • {{#if: UbuntuHelp:Git|中文| [[::Git/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/zh-hans | • {{#if: UbuntuHelp:Git|中文(简体)| [[::Git/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Git | UbuntuHelp:Git | {{#if: | :}}Git}}/zh-hant | • {{#if: UbuntuHelp:Git|中文(繁體)| [[::Git/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:Git|:Git|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Git/zh | | {{#ifexist: Git/zh | | {{#ifeq: {{#titleparts:Git|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Git|1|-1|}} | zh | | }}
Introduction
Git is an 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.
Installation
Following these instructions we assume you already have a Ubuntu 9.04 installed on you computer/server and that you already have a public ssh key on your machine you can use that to initialize the repository (Don't have one, look here). The following instructions will guide you on how to set up and run a fully managed hosting for projects using git on your server.
Used software
This tutorial was done using an Ubuntu 9.04 (Jaunty Jackalope). We'll be using the latest git package available in the archive. For git project management will be using Gitosis. For repository web browsing we will be using ViewGit. The latest version we will clone directly from a git repository: git clone git://repo.or.cz/viewgit.git
Setting up Git and Project Management
Use your favorite package installer to install git-core and gitosis packages:
apt-get -y install git-core gitosis
Now that you should have both packages installed, we can set up gitosis. First copy your public key to the server:
scp .ssh/id_rsa.pub [email protected]:/tmp
Initialize gitosis using your copied key:
sudo -H -u gitosis gitosis-init < /tmp/id_rsa.pub
Once you saw some output like this: `Initialized empty Git repository in ./` Your gitosis is installed. You can now remove the copied key.
rm /tmp/id_rsa.pub
Once done, you can now checkout the gitosis-admin branch on your local machine:
git clone [email protected]:gitosis-admin.git
Note: If the cloning doesn't work, maybe you have "PermitRootLogin no" in the SSH Server and you need to add gitosis user to it.
sudo vim /etc/ssh/sshd_config AllowUsers gitosis
Use your favorite editor to modify the contents of the gitosis configuration file:
cd gitosis-admin vim gitosis.conf
Adding a new project to the repository
Here is an example of the gitosis configuration file you clone before. Here it contains the default gitosis entry, and a new project entry:
[gitosis] [group team] writable = testproject members = hostname.yourserver.com [group gitosis-admin] writable = gitosis-admin members = keyfilename
`hostname.yourserver.com` or `keyfilename` is the name of the public key without `.pub` extension you copied into `gitosis-admin/keydir/` directory. After you've done editing, save the file, and commit it back to the server.
git commit -a -m "Added a new project" git push
Any future projects will be added the same way.
Committing to the first project
To commit the project you just created, initiate a new git project, add files to it, commit it, then push it to your repository with the name you set up in gitosis config file.
mkdir testproject cd testproject git init touch a_text_file.txt git add . git commit -a -m "Initial import" git remote add origin [email protected]:testproject.git git push origin master
The project should be committed! {i} If not, please check your `/srv/gitosis/.ssh/authorized_keys` file, if that one contains your correct public key!
Adding users
First, gather their public SSH keys, which I'll call "kakashi.pub" and "naruto.pub", and drop them into keydir/ of your local gitosis-admin repository. Second, edit gitosis.conf and add them to the "members" list.
cd gitosis-admin cp ~/kakashi.pub keydir/ cp ~/naruto.pub keydir/ git add keydir/kakashi.pub keydir/naruto.pub
Note that the key filename must have a ".pub" extension. gitosis.conf changes:
[group team] writable = testproject - members = hostname.yourserver.com + members = hostname.yourserver.com kakashi naruto
Commit and push:
git commit -a -m "Granted Kakashi and Naruto commit rights to testproject" git push
That's it. Kakashi and Naruto can now clone the testproject repository like so:
git clone [email protected]:testproject.git
Kakashi and Naruto will also have commit rights.
The web browsing interface
Server will need a web server so I recommend you to install Apache with support for php. Once ViewGit can be linked to GeSHI, I also recommend you installing the `php-geshi` package:
sudo apt-get install apache2 libapache2-mod-php5 php-geshi
{i} For more extended Apache installation we recommend you reading a dedicated page like this ApacheMySQLPHP. Once done, `/var/www/` directory will be created. Go there and clone the latest git version of ViewGIT:
cd /var/www sudo git clone git://repo.or.cz/viewgit.git sudo chown -vR www-data:www-data viewgit
After finishing this operation, use your favorite editor to edit the config file for ViewGit:
cd /var/www/viewgit/inc sudo cp config.php localconfig.php sudo chown www-data:www-data localconfig.php sudo vim localconfig.php
Here is an example of the ViewGit `localconfig.php` with GeSHI and the testproject.git we created:
<nowiki> <?php $conf['projects'] = array( 'projectname' => array('repo' => '/srv/gitosis/repositories/testproject.git/'), ); // Where git is. Default is to search from PATH, but you can use an absolute // path as well. $conf['git'] = 'git'; // If set, contains an array of globs/wildcards where to include projects. // Use this if you have a lot of projects under a directory. //$conf['projects_glob'] = array('/path/to/*/.git', '/var/git/*.git'); $conf['datetime'] = '%Y-%m-%d %H:%M'; // More complete format for commit page $conf['datetime_full'] = '%Y-%m-%d %H:%M:%S'; // Maximum length of commit message's first line to show $conf['commit_message_maxlen'] = 50; // Maximum number of shortlog entries to show on the summary page $conf['summary_shortlog'] = 30; // Maximum number of tags to show on the summary page $conf['summary_tags'] = 10; // Whether to show remote labels on shortlog $conf['shortlog_remote_labels'] = false; // Allow checking out projects via "git clone" $conf['allow_checkout'] = true; // If set, this function is used to obfuscate e-mail addresses of authors/committers // The 'obfuscate_mail' function simply replaces @ with ' at ' and . with ' dot ' //$conf['mail_filter'] = 'obfuscate_mail'; //$conf['mail_filter'] = create_function('$mail', 'return str_rot13(strtoupper($mail));'); // Whether to use GeSHi for source highlighting $conf['geshi'] = true; // Path to geshi.php $conf['geshi_path'] = 'inc/geshi/geshi.php'; $conf['geshi_path'] = '/usr/share/php-geshi/geshi.php'; // Path on Debian // Use line numbers in geshi? // Setting this to "false" disables line numbers // Using a value of 0 will enable "NORMAL" geshi line numbers // Using values of 1 or more will enable "FANCY" geshi line numbers $conf['geshi_line_numbers'] = 5; // RSS time to live (how often clients should update the feed), in minutes. $conf['rss_ttl'] = 10; // RSS: Maximum number of items in feed $conf['rss_max_items'] = 30; // RSS item format. Allowed formatting: // {AUTHOR}, {AUTHOR_MAIL}, {SHORTLOG}, {LOG}, {COMMITTER}, {COMMITTER_MAIL}, {DIFFSTAT} $conf['rss_item_title'] = '{SHORTLOG} ({AUTHOR})'; $conf['rss_item_description'] = '<pre>{LOG}
{AUTHOR} <{AUTHOR_MAIL}>
{DIFFSTAT}
';
$conf['debug'] = false;
// Includes a small link to the ViewGit homepage on each page $conf['ad'] = false;
</nowiki>
Now you should be able to browse your Git repository by going to http://localhost/viewgit/ if you got problems on accessing repositories, add your web server user to the same group gitosis user is:
adduser www-data git
Making available public cloning of the projects
To make available public access for cloning of the projects, you have to set up git-daemon. git-daemon is a service which runs on port `9418` and handles public requests for project cloning. git-daemon comes together with git-core so no additional installation is required. To make this service easier to administrate, here is an init script to start and stop the daemon. It is, however, easier to make git a subservice of xinetd, by editing /etc/xinetd.d/git and changing disable=no to disable=yes.
#! /bin/sh # Taken from here: http://pastie.org/227647 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=git-daemon PIDFILE=/var/run/$NAME.pid DESC="the git daemon" DAEMON=/usr/lib/git-core/git-daemon DAEMON_OPTS="--base-path=/srv/gitosis/repositories --export-all --verbose --syslog --detach --pid-file=$PIDFILE --user=gitosis --group=nogroup" test -x $DAEMON || exit 0 [ -r /etc/default/git-daemon ] && . /etc/default/git-daemon . /lib/lsb/init-functions start_git() { start-stop-daemon --start --quiet --pidfile $PIDFILE \ --startas $DAEMON -- $DAEMON_OPTS } stop_git() { start-stop-daemon --stop --quiet --pidfile $PIDFILE rm -f $PIDFILE } status_git() { start-stop-daemon --stop --test --quiet --pidfile $PIDFILE >/dev/null 2>&1 } case "$1" in start) log_begin_msg "Starting $DESC" start_git log_end_msg 0 ;; stop) log_begin_msg "Stopping $DESC" stop_git log_end_msg 0 ;; status) log_begin_msg "Testing $DESC: " if status_git then log_success_msg "Running" exit 0 else log_failure_msg "Not running" exit 1 fi ;; restart|force-reload) log_begin_msg "Restarting $DESC" stop_git sleep 1 start_git log_end_msg 0 ;; *) echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac exit 0
To make it usable, and make possible it's automatic startup on server boot change its permissions and update-rc.d
sudo chmod +x /etc/init.d/git-daemon sudo update-rc.d git-daemon defaults
The daemon can be started or stoped by accesing:
sudo /etc/init.d/git-daemon start sudo /etc/init.d/git-daemon stop