Ceci est une ancienne révision du document !
Table des matières
Git
Git est un gestionnaire de versions (comme svn, cvs ou d'autres) décentralisé.
Bonne doc en français sur http://alexgirard.com/git-book/index.html
Mais, parfois, la centralisation s'avère pratique, et c'est aussi possible.
Cf http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way, http://www.nikrou.net/post/2009/02/20/Mettre-en-place-un-d%C3%A9p%C3%B4t-central-git ou http://blog.touv.fr/2009/06/depot-git-prive-et-personnel-sur.html pour l'install du dépot central.
Ensuite, quelques liens utiles
Opérations courantes
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#git-quick-start
# transformer le dossier courant en projet git git init # ajouter tous ses fichiers au projet (ou bien préciser les fichiers à ajouter) git add . # ajouter un alias pour un projet sur un serveur distant git remote add alias_de_ce_projet_sur_ce_serveur user@server:path/2/le_projet.git # y envoyer les fichiers git push alias_de_ce_projet_sur_ce_serveur la_branche # "master" pour la branche principale # commit d`un fichier (localement) git commit -m 'message de commit' le_fichier # commit de tous les fichiers (localement) git commit -m 'message de commit' -a # envoi de tous les derniers commit (depuis le dernier push) sur le serveur git push
Script de démarrage
Mon script d'init /etc/init.d/git-daemon (basé sur /etc/init.d/skeleton)
#!/bin/sh ### BEGIN INIT INFO # Provides: git-daemon # Required-Start: $networking # Required-Stop: $networking # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start/stop git-daemon to handle git protocol # Description: The daemon is launched under the git user ### END INIT INFO # Author: Daniel Caillibaud <daniel@edulibre.org> PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="git-daemon (which handles git protocol on 9418 port)" NAME=git-daemon DAEMON=/usr/bin/$NAME # DAEMON_ARGS later (after default conf load) PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # start-stop-daemon options SSD_OPTIONS='--chuid git:git --nicelevel 5 --background' # git-daemon doesn't detach himself # Exit if the package is not installed [ ! -x "$DAEMON" ] && log_daemon_msg "$DAEMON doesn't exist" && echo "$DAEMON doesn't exist" > 2 && exit 0 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME DAEMON_ARGS="--base-path=$GIT_REPOSITORIES" # GIT_REPOSITORIES is in /etc/default/git-daemon # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon $SSD_OPTIONS --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon $SSD_OPTIONS --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 } # # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE return "$RETVAL" } case "$1" in start) log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; restart) log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 exit 3 ;; esac
Avec les prefs
echo 'GIT_REPOSITORIES=/home/git/repositories/' > /etc/default/git-daemon
Mais tout ça sert pas à grand chose car il y a un paquet git-daemon-run, qui, comme son nom l'indique…
Bref, ce qui suit va quand même plus vite
aptitude install git-daemon-run ln -s /usr/bin/sv /etc/init.d/git-daemon # et on va modifier /etc/sv/git-daemon/run pour préciser le --base-path