subversion

subversionとは
バージョン管理ツールの一種です。バージョン管理とは、ファイルを世代管理します。
プログラムソースやドキュメントなどの、常に変更が加わるようなファイルの差分を保持します。

■ インストール
yumでインストール

[root@example ~]# yum install subversion

subversion用のアカウントの作成
user:svn,group:svnで作成します。

グループの作成
[root@example ~]# groupadd svn

ユーザの作成
[root@example ~]# useradd svn -g svn

■ サンプルプロジェクトのインポート
試しに、プロジェクトをsvnで管理してみます。
慣例として、trunk・branches・tagsディレクトリを作成して、それぞれをサンプルプロジェクトにインポートします。
ここからの操作はsvnユーザで行います。

リポジトリの作成
[svn@example ~]$ mkdir -p /home/svn/repos/sampleproject
[svn@example ~]$ svnadmin create /home/svn/repos/sampleproject

リポジトリにインポートするディレクトリを作成
[svn@example ~]$ mkdir -p /tmp/sampleproject/trunk
[svn@example ~]$ mkdir -p /tmp/sampleproject/branches
[svn@example ~]$ mkdir -p /tmp/sampleproject/tags

インポート
[svn@example ~]$ svn import /tmp/sampleproject file://localhost/home/svn/repos/sampleproject -m "import"

インポートに使用したディレクトリを削除
[svn@example ~]$ rm -rf /tmp/sampleproject

rootで権限の変更
[root@example ~]# chmod -R 755 /home/svn/repos

■ チェックアウト/コミット
クライアントからチェックアウト/コミットをしてみます。

テストユーザの作成
[root@example ~]# useradd testuser -g svn

ユーザの変更
[root@example ~]# su testuser

チェックアウト
[testuser@example ~]$ svn checkout file://localhost/home/svn/repos/sampleproject sampleproject
A sampleproject/trunk
A sampleproject/branches
A sampleproject/tags
リビジョン 1 をチェックアウトしました。

trunkに移動
[testuser@example ~]$ cd /home/testuser/sampleproject/trunk

適当なファイルを作成
[testuser@example trunk]$ vi test.html
hoge

リポジトリに追加
[testuser@example trunk]$ svn add test.html
A test.html

test.htmlを適当に編集
[testuser@example trunk]$ vi test.html
hogehoge

差分の確認
[testuser@example trunk]$ svn diff test.html
Index: test.html
===================================================================

      • test.html (リビジョン 0)
      1. test.html (リビジョン 0)

@@ -0,0 +1 @@

  1. hogehoge

コミット
[testuser@example ~]$ svn commit -m "test commit" test.html
追加しています test.html
ファイルのデータを送信しています .
リビジョン 2 をコミットしました。

※ 2009/06/07更新