2012-03-07

CentOSでgitサーバ構築

CentOSにyumでgit git-daemonをインストールして設定変更を行う
yum -y install git git-daemon
cat <<"EOF" > /etc/xinet.d/git
# default: off
# description: The git dæmon allows git repositories to be exported using \
#       the git:// protocol.

service git
{
        disable         = no
        socket_type     = stream
        wait            = no
        user            = git
        server          = /usr/bin/git-daemon
        server_args     = --base-path=/mnt/git-repos --export-all --user-path=public_git --syslog --inetd --verbose
        log_on_failure  += USERID
        # xinetd does not enable IPv6 by default
#       flags           = IPv6
}
EOF
起動ユーザを追加、レポジトリ用ディレクトリの作成、カラのレポジトリの作成をしてxinetdを再起動
useradd git
mkdir -p /mnt/git-repos
git init --bare /mnt/git-repos/test.git
chown -R git:git /mnt/git-repos
service xinetd restart
クライアントからpushとcloneのテスト push TortoiseGitをインストールしてwindowsからテストを行った。
PuTTY Key Generatorでサーバに接続するための秘密鍵を作成するかputty用に変換する
TourtoiseGitのsettingsでGit->RemoteのところにRemoteレポジトリの設定をする
URLはssh://UserName@xxx.xxx.xxx.xxx/mnt/git-repos/test.git
ローカルレポジトリを作成してpushしてみる

clone
TourtoiseGitのGit Cloneを選択し、URLにgit://176.34.35.143/test.gitを入力して実行

※はまりどころ
* flagsのIPv6の行をコメントアウトしてあげないとdaemonが起動しなかった
* gitプロトコルでpushできるようにするには/etc/xinet.d/gitのserver_argsに--enable=receive-packを追加しなくてはいけない
* gitプロトコルのgit://のURLでは少なくともwindowsのgitクライアントからはpushできなかった

Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (6/6)
な感じで止まってしまう。
* pushの際のサーバ側のパスは/からのフルパスで指定するssh://xxx.xxx.xxx.xxx/mnt/git-repos/hoge.git

0 件のコメント:

コメントを投稿