2012-03-07

CentOSでgitサーバ構築

CentOSにyumでgit git-daemonをインストールして設定変更を行う
  1. yum -y install git git-daemon  
  2. cat <<"EOF" > /etc/xinet.d/git  
  3. # default: off  
  4. # description: The git dæmon allows git repositories to be exported using \  
  5. #       the git:// protocol.  
  6.   
  7. service git  
  8. {  
  9.         disable         = no  
  10.         socket_type     = stream  
  11.         wait            = no  
  12.         user            = git  
  13.         server          = /usr/bin/git-daemon  
  14.         server_args     = --base-path=/mnt/git-repos --export-all --user-path=public_git --syslog --inetd --verbose  
  15.         log_on_failure  += USERID  
  16.         # xinetd does not enable IPv6 by default  
  17. #       flags           = IPv6  
  18. }  
  19. EOF  
起動ユーザを追加、レポジトリ用ディレクトリの作成、カラのレポジトリの作成をしてxinetdを再起動
  1. useradd git  
  2. mkdir -p /mnt/git-repos  
  3. git init --bare /mnt/git-repos/test.git  
  4. chown -R git:git /mnt/git-repos  
  5. 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できなかった

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

0 件のコメント:

コメントを投稿