外部サービスは使わずに自力でCentOS6系にGitサーバを構築してみます。
やってみたら想像以上に簡単でした。
# yum install git git-deamon git-all
# vi /etc/xinetd.d/git
service git { disable = no socket_type = stream wait = no user = nobody server = /usr/libexec/git-core/git-daemon server_args = --base-path=/var/lib/git --export-all --user-path=public_git --syslog --inetd --verbose log_on_failure += USERID }
# /etc/rc.d/init.d/xinetd restart
# cd /var/lib/git/ # mkdir -p public_git/test.git # cd public_git/test.git # git --bare init --shared # cd .. # chown -R root:git test.git
# groupadd git
userアカウントをgitグループへ追加する場合
# usermod -aG git user
# useradd -g git gituser
追加後に /etc/passwd を編集して、該当ユーザーのシェルを
/usr/bin/git-shell
へ変更します。
適当なフォルダ test を作成し、上記で作成したリポジトリに対してクライアントTortoiseGitにて「Git クローン(複製)」を実行
URLは以下
ssh://user@example.com/var/lib/git/public_git/test.git
これでGitにて管理できるようになります。
# cd /var/lib/git/public_git # mkdir test2.git # cd test2.git # git --bare init --shared # cd .. # chown -R root:git test2.git
URLは以下になります。
ssh://user@example.com/var/lib/git/public_git/test2.git
$ cd /home $ mkdir test $ cd test $ git clone ssh://user@127.0.0.1/var/lib/git/public_git/test.git ./
プルする場合は
$ git pull