ブランチを作成するとき、以下を選択するとどのような影響がありますか?
以下からリポジトリにコピーを作成します。
- リポジトリの HEAD リビジョン
- リポジトリの特定のリビジョン
- ワーキングコピー
ブランチを作成するとき、以下を選択するとどのような影響がありますか?
以下からリポジトリにコピーを作成します。
要するに:
ブランチを作成する目的に応じて、通常は最初の 2 つのオプションのいずれかを選択します。3 番目のオプションは、おそらくあまり使用されません。
特定の目的のために探索的開発を行いたい場合や、特定の顧客などのために別のバージョンの作成を開始したい場合は、HEAD から分岐します。ソフトウェアの以前にリリースされたバージョンにパッチを作成する必要がある場合は、過去から分岐します。
svn での「ブランチの作成」は、実際にはリポジトリのサブセットのコピーを作成するだけです。実際、分岐に関する SVN Book の章には、多くのことが書かれています。
ディレクトリ構造がこのような場合…</p>
トランクへの URL が:http://example.com/repos/project/trunk
の場合、次のようになります。
beta
次のようにHEAD から名前を付けた新しいブランチを作成します。
svn copy http://example.com/repos/project/trunk http://example.com/repos/project/branches/beta
これにより、リポジトリに新しいブランチがすぐに作成され、ローカル コピーには何も行われません。
次のようにancient
、古いリビジョンnから名前を付けた新しいブランチを作成します。
svn copy -r n http://example.com/repos/project/trunk http://example.com/repos/project/branches/ancient
これは1とまったく同じですが、特定のリビジョンを使用します。
alpha
現在のディレクトリがtrunk
:
cd ../
svn cp trunk branches/alpha
これにより、要求したコピーが作成されますが、ローカルで行われます。SVN book によると、リポジトリ サーバーでコピーを作成するよりもはるかに時間がかかるため、これはお勧めできません (コピー操作は基本的に無料です)。
次のように入力すると、次の警告が表示されますsvn help copy
。
警告: 以前のバージョンの Subversion との互換性のために、2 つの作業コピー パス (WC -> WC) を使用して実行されたコピーはリポジトリにアクセスしません。そのため、デフォルトでは、マージ追跡情報をコピー元からコピー先に伝達できない場合があります。
私の経験では、通常は方法1が使用されます。2は、以前のブランチへの複雑なパッチを含むいくつかのまれなケースで使用され、3は決して役に立ちません (ドキュメントによると、遅く、おそらく危険です)。したがって、他の 2 つのいずれかを使用するやむを得ない理由がない限り、 1を使用してください。
HEAD revision in the repository SVN takes the Revision with the highest number so the one which was uploaded last.
Specific revision the repository You can select the revision you would like to get.
Working copy The revision like it is right now in your local workspace (not comitted).
HEAD will cause the branch to be a copy of the latest committed version of the repository.
Specific revision will cause the branch to be a copy at a specific point in time of the repository.
Working copy creates a branch based on your working copy's latest revision and then commits to this all of your "in progress" changes as well.
EDIT: An example for choosing Working Copy.
You update your working copy with the latest version of the trunk to start making some minor changes.
You realise after a few hours that the job was bigger than you expected and you should've created a branch.
Creating a branch from Working Copy at this point then effectively creates the branch as if you had done it at the beginning.