CentOS6.4 64bitにgitサーバー構築

# yum install git git-daemon git-all xinetd
# chkconfig xinetd on
# /etc/init.d/xinetd start
xinetd を起動中: [ OK ]

git-daemonファイルを作成

# vi /etc/xinetd.d/git-daemon

                                                                        • -

# 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 = 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/init.d/xinetd restart

レポジトリ作成
# cd /var/lib/git
# mkdir repos
# mkdir repos/test.git
# cd repos/test.git/
# git --bare init --shared
Initialized empty shared Git repository in /var/lib/git/repos/test.git/

テスト用のファイル作成
$ cd
$ mkdir git_test
$ cd git_test
$ echo "Git Test." > test.txt
このディレクトリ内にローカルリポジトリを作成
$ git init
Initialized empty Git repository in /home/nabe/git_test/.git/

ファイルをローカルリポジトリに追加し、コミットする。
$ git add test.txt
$ git commit -m "First Commit"

リモートリポジトリの登録(登録名test)
登録名を省略するとデフォルトでorigin になる。
$ git remote add test ssh://localhost/var/lib/git/repos/test.git


$ git push test master The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is eb:23:b3:23:4e:d1:f8:fa:90:10:62:a5:9b:ac:d7:9a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
nabe@localhost's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 227 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://localhost/var/lib/git/repos/test.git
* [new branch] master -> master

リモートリポジトリから Pull
$ git pull test master
nabe@localhost's password:
From ssh://localhost/var/lib/git/repos/test
* branch master -> FETCH_HEAD
Already up-to-date.