3 Licensed to the Apache Software Foundation (ASF) under one
4 or more contributor license agreements. See the NOTICE file
5 distributed with this work for additional information
6 regarding copyright ownership. The ASF licenses this file
7 to you under the Apache License, Version 2.0 (the
8 "License"); you may not use this file except in compliance
9 with the License. You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing,
14 software distributed under the License is distributed on an
15 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 KIND, either express or implied. See the License for the
17 specific language governing permissions and limitations
21 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
22 "http://www.w3.org/TR/html4/strict.dtd">
25 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
26 <title>CVS to SVN Crossover Guide</title>
27 <style type="text/css">
29 font-family: sans-serif;
39 border-left: 4px #b0c0f0 solid;
57 .sidebyside th, .sidebyside td {
59 border-width: 0 1px 2px 0;
77 <h1>CVS to SVN Crossover Guide</h1>
79 <!-- ==================================================================== -->
83 <p>This document provides an alternate method of learning Subversion.
84 Many users dislike learning new technology via a theoretical "top
85 down" approach, as provided by the <a
86 href="http://svnbook.red-bean.com">Subversion Book</a>. Instead,
87 this document presents Subversion from the "bottom up": it shows a
88 CVS command or task, and then shows the equivalent task in
89 Subversion (along with relevant book links.) It's essentially a
90 re-indexing of topics covered by the book, keyed on CVS tasks.</p>
94 <!-- ==================================================================== -->
96 <h2>Table of Contents</h2>
100 <li><a href="#repos_creation">Repository creation</a></li>
101 <li><a href="#import">Importing data</a></li>
102 <li><a href="#installing">Installing a server</a></li>
103 <li><a href="#authenticating">Authenticating to a server</a></li>
104 <li><a href="#browsing">Browsing a repository</a></li>
105 <li><a href="#checkingout">Checking out a working copy</a></li>
108 <h3>Basic Work Cycle</h3>
110 <li><a href="#changeditems">Seeing locally changed items</a></li>
111 <li><a href="#outofdate">Seeing out-of-date items</a></li>
112 <li><a href="#scheduling">Scheduling additions or deletions</a></li>
113 <li><a href="#copying">Copying and moving</a></li>
114 <li>Undoing local changes</li>
115 <li>Updating and committing</li>
116 <li>Resolving conflicts</li>
117 <li>Adding a binary file</li>
118 <li>Using native line-endings</li>
121 <h3>Examining history</h3>
123 <li>Seeing history of an item</li>
124 <li>Comparing two versions of an item</li>
127 <h3>Branching/Tagging/Merging</h3>
129 <li>Creating a branch</li>
130 <li>Moving a working copy to a branch</li>
131 <li>Finding the beginning of a branch</li>
132 <li>Porting a single change</li>
133 <li>Merging a whole branch</li>
134 <li>Reverting a committed change</li>
135 <li>Resurrecting deleted items</li>
136 <li>Creating a tag</li>
137 <li>Tweaking a tag</li>
138 <li>Seeing all tags</li>
139 <li>Comparing two tags</li>
140 <li>Seeing logs between two tags</li>
145 <li>Using modules</li>
146 <li>Line endings and keywords</li>
151 <!-- ==================================================================== -->
153 <h2 id="repos_creation">Repository creation</h2>
155 <p>Create a new repository for holding versioned data.</p>
157 <table class="sidebyside">
166 <dd><tt>$ cvs -d /usr/local/repos init</tt></dd>
168 <dt>Explanation:</dt>
169 <dd>Creates a new directory <tt>repos</tt> ready to hold RCS
170 files and config scripts.</dd>
176 <dd><tt>$ svnadmin create /usr/local/repos</tt></dd>
178 <dt>Explanation:</dt>
179 <dd>Creates a new directory <tt>repos</tt> containing BerkeleyDB
180 files and config scripts.</dd>
187 <dt>Book References:</dt>
188 <dd><a href="http://svnbook.red-bean.com/svnbook/ch05s02.html">Repository Creation and Configuration</a></dd>
193 <!-- ==================================================================== -->
195 <h2 id="import">Importing data</h2>
197 <p>Populate a new repository with initial data. Assuming that you
198 have a tree of code in the local directory <tt>myproj/</tt>, and
199 you want to move this tree into the repository.</p>
201 <table class="sidebyside">
210 <dd><tt>$ cd myproj</tt></dd>
211 <dd><tt>$ cvs -d /usr/local/repos import myproj/ none start</tt></dd>
213 <dt>Explanation:</dt>
215 <dd>This copies the contents of the current working directory to
216 a new directory (<tt>myproj</tt>) in the CVS repository. The
217 CVS repository now contains a directory <tt>/myproj/</tt> at the
225 <dd><tt>$ svn mkdir file:///usr/local/repos/tags</tt></dd>
226 <dd><tt>$ svn mkdir file:///usr/local/repos/branches</tt></dd>
227 <dd><tt>$ svn import myproj/ file:///usr/local/repos/trunk</tt></dd>
229 <dt>Explanation:</dt>
231 <dd>Though not strictly required, we deliberately create
232 <tt>/tags</tt> and <tt>/branches</tt> top-level directories in
233 the repository, to hold tags and branches later on. Then we
234 import the contents of the local <tt>myproj/</tt> directory into
235 a newly created <tt>/trunk</tt> directory in the
243 <dt>Book References:</dt>
244 <dd><a href="http://svnbook.red-bean.com/svnbook/ch05s04.html#svn-ch-5-sect-6.1">Choosing a repository layout</a></dd>
245 <dd><a href="http://svnbook.red-bean.com/svnbook/re12.html">svn import</a></dd>
249 <!-- ==================================================================== -->
251 <h2 id="installing">Installing a server</h2>
253 <p>Make the repository available to clients via a network.</p>
255 <table class="sidebyside">
264 <dd>(too complex to demonstrate here)</dd>
266 <dt>Explanation:</dt>
267 <dd>Export the repository via the cvs <em>pserver</em> program.
268 It can be launched by either <strong>inetd</strong> or a
269 client's <strong>ssh</strong> remote request.</dd>
276 <dd>(too complex to demonstrate here)</dd>
278 <dt>Explanation:</dt>
279 <dd>Export the repository with the <em>Apache 2.0.x</em> server,
280 or via the <em>svnserve</em> program. The latter can run as a
281 standalone daemon, can be launched by <strong>inetd</strong>, or
282 invoked by a client's <strong>ssh</strong> remote request.</dd>
290 <dt>Book References:</dt>
291 <dd><a href="http://svnbook.red-bean.com/svnbook/ch06.html">Server configuration</a></dd>
296 <!-- ==================================================================== -->
298 <h2 id="authenticating">Authenticating to a server</h2>
300 <p>Have a network client prove its identity to a version
303 <table class="sidebyside">
312 <dd><tt>$ cvs -d :pserver:user@host:/repos <em>command</em>…</tt></dd>
314 <dt>Explanation:</dt>
316 <dd>When contacting a repository, the client pre-emptively
317 "pushes" its authentication credentials at the server.</dd>
324 <dd><tt>$ svn <em>command</em> <em>URL</em>…</tt></dd>
325 <dd><tt>Password for 'user': XXXXXXX</tt></dd>
327 <dt>Explanation:</dt>
329 <dd>The client's authentication credentials are "pulled" from
330 the user interactively, and only when the server deems that a
331 challenge needs to be made. (And contrary to popular belief,
332 the <tt>--username</tt> and <tt>--password</tt> options are
333 merely values to be used <em>if</em> the server issues a
334 challenge; they do not "push" the credentials at the
343 <dt>Book References:</dt>
344 <dd><a href="http://svnbook.red-bean.com/svnbook/ch06s02.html">Network Model</a></dd>
349 <!-- ==================================================================== -->
351 <h2 id="browsing">Browsing a repository</h2>
353 <p>Browse the repository as a filesystem, perusing file
354 contents and history as well (older versions of files or
357 <table class="sidebyside">
366 <dd>(not possible with commandline client)</dd>
368 <dt>Explanation:</dt>
370 <dd>Not possible with commandline client. A third-party web
371 server tool such as ViewCVS must be used.</dd>
378 <dd><tt>$ svn list <em>URL</em> [-r <em>rev</em>] [-v]</tt></dd>
379 <dd><tt>$ svn cat <em>URL</em> [-r <em>rev</em>]</tt></dd>
381 <dt>Explanation:</dt>
383 <dd>The <tt>svn list</tt> and <tt>svn cat</tt> commands allow
384 interactive browsing of a repository (and all previous states of
385 a repository) from the commandline. (The <tt>--verbose [-v]</tt>
386 switch displays full listing information.) If Apache is being
387 used as a Subversion server process (i.e. clients access via
388 <strong>http://</strong>), then the latest version of the
389 repository can be directly browsed by entering <em>URL</em> into
390 any web browser. Additionally, a third-party web server tool
391 (such as ViewCVS) can be used with Subversion.</dd>
399 <dt>Book References:</dt>
400 <dd><a href="http://svnbook.red-bean.com/svnbook/re14.html">svn list</a></dd>
405 <!-- ==================================================================== -->
407 <h2 id="checkingout">Checking out a working copy</h2>
409 <p>Create a workspace on local disk which mirrors a directory
410 in the repository.</p>
412 <table class="sidebyside">
421 <dd><tt>$ cvs -d /usr/local/repos checkout myproj</tt></dd>
422 <dd><tt>U myproj/foo.c</tt></dd>
423 <dd><tt>U myproj/bar.c</tt></dd>
424 <dd><tt>…</tt></dd>
426 <dt>Explanation:</dt>
428 <dd>Creates a local directory <tt>myproj</tt> which is a mirror
429 of the repository directory <tt>/myproj</tt>.</dd>
436 <dd><tt>$ svn checkout file:///usr/local/repos/trunk myproj</tt></dd>
437 <dd><tt>A myproj/foo.c</tt></dd>
438 <dd><tt>A myproj/bar.c</tt></dd>
439 <dd><tt>…</tt></dd>
441 <dt>Explanation:</dt>
443 <dd>Assuming that the original project data was imported into
444 the repository <tt>/trunk</tt> directory, this creates a local
445 directory <tt>myproj</tt> which is a mirror of the repository
446 directory <tt>/trunk</tt>. Standard Subversion convention is to
447 do "mainline" development in <tt>/trunk</tt>. See branching and
448 tagging sections for more details.</dd>
456 <dt>Book References:</dt>
457 <dd><a href="http://svnbook.red-bean.com/svnbook/ch03s04.html">Initial Checkout</a></dd>
458 <dd><a href="http://svnbook.red-bean.com/svnbook/re04.html">svn checkout</a></dd>
463 <!-- ==================================================================== -->
465 <h2 id="changeditems">Seeing locally changed items</h2>
467 <p>Discover which items in the working copy have local
468 modifications or are scheduled for addition/deletion.</p>
470 <table class="sidebyside">
479 <dd><tt>$ cvs status</tt></dd>
480 <dd><tt>…</tt></dd>
481 <dd><tt>File: baz.c Status: Up-to-date</tt></dd>
482 <dd><tt>…</tt></dd>
483 <dd><tt>$ cvs update</tt></dd>
484 <dd><tt>M foo.c</tt></dd>
485 <dd><tt>U bar.c</tt></dd>
486 <dd><tt>…</tt></dd>
488 <dt>Explanation:</dt>
490 <dd>The <tt>cvs status</tt> command shows whether a file is
491 locally modified or out of date, including information about
492 working revision and branch info. Unfortunately, because the
493 output is so verbose and hard to read, many users run <tt>cvs
494 update</tt> instead, which shows a more compact listing of
495 modified files (and of course, it also causes the server to
496 merge changes into your working copy.)</dd>
503 <dd><tt>$ svn status</tt></dd>
504 <dd><tt>M foo.c</tt></dd>
505 <dd><tt>…</tt></dd>
507 <dt>Explanation:</dt>
509 <dd>Shows modified files only. Very fast, as it does not use
510 the network. Does not update your working copy, yet still shows
511 a single-line display, much like <tt>svn update</tt>. To see
512 working revision and branch information, run <tt>svn info</tt>.</dd>
520 <dt>Book References:</dt>
521 <dd><a href="http://svnbook.red-bean.com/svnbook/ch03s05.html#svn-ch-3-sect-4.3.1">Examine Your Changes</a></dd>
522 <dd><a href="http://svnbook.red-bean.com/svnbook/re26.html">svn status</a></dd>
527 <!-- ==================================================================== -->
529 <h2 id="outofdate">Seeing out-of-date items</h2>
531 <p>Discover which items in the working copy are out-of-date
532 (i.e. newer versions exist in the repository.)</p>
534 <table class="sidebyside">
543 <dd><tt>$ cvs status</tt></dd>
544 <dd><tt>…</tt></dd>
545 <dd><tt>File: baz.c Status: Needs Patch</tt></dd>
546 <dd><tt>…</tt></dd>
547 <dd><tt>$ cvs -n update</tt></dd>
548 <dd><tt>M foo.c</tt></dd>
549 <dd><tt>U bar.c</tt></dd>
550 <dd><tt>…</tt></dd>
552 <dt>Explanation:</dt>
554 <dd>The <tt>cvs status</tt> command shows whether a file is
555 locally modified or out of date, including information about
556 working revision and branch info. A less verbose option is to
557 run <tt>cvs -n update</tt> instead, which shows a compact
558 listing of both out-of-date and locally modified files, without
559 actually updating the working copy.</dd>
566 <dd><tt>$ svn status -u</tt></dd>
567 <dd><tt>M 46 foo.c</tt></dd>
568 <dd><tt>M * 46 bar.c</tt></dd>
569 <dd><tt> * 46 baz.c</tt></dd>
570 <dd><tt>…</tt></dd>
572 <dt>Explanation:</dt>
574 <dd>Shows modified files (<tt>M</tt>) as well as out-of-date
575 files (<tt>*</tt>). Contacts repository, but doesn't modify the
576 working copy. To see working revision and branch information,
577 run <tt>svn info</tt>.</dd>
585 <dt>Book References:</dt>
586 <dd><a href="http://svnbook.red-bean.com/svnbook/ch03s05.html#svn-ch-3-sect-4.3.1">Examine Your Changes</a></dd>
587 <dd><a href="http://svnbook.red-bean.com/svnbook/re26.html">svn status</a></dd>
592 <!-- ==================================================================== -->
594 <h2 id="scheduling">Scheduling additions or deletions</h2>
596 <p>Schedule a working-copy file or directory to be added or
597 removed from the repository.</p>
599 <table class="sidebyside">
608 <dd><tt>$ touch foo.c</tt></dd>
609 <dd><tt>$ cvs add foo.c</tt></dd>
610 <dd><tt>cvs server: scheduling file `blah' for addition</tt></dd>
611 <dd><tt>cvs server: use 'cvs commit' to add this file permanently</tt></dd>
612 <dd><tt> </tt></dd>
613 <dd><tt>$ mkdir new-dir</tt></dd>
614 <dd><tt>$ cvs add new-dir</tt></dd>
615 <dd><tt>Directory new-dir added to the repository</tt></dd>
616 <dd><tt> </tt></dd>
617 <dd><tt>$ rm bar.c</tt></dd>
618 <dd><tt>$ cvs rm bar.c</tt></dd>
619 <dd><tt>cvs remove: scheduling `bar.c' for removal</tt></dd>
620 <dd><tt>cvs remove: use 'cvs commit' to remove this file permanently</tt></dd>
621 <dd><tt> </tt></dd>
622 <dd><tt>$ rm -rf old-dir/*</tt></dd>
623 <dd><tt>$ cvs rm old-dir</tt></dd>
624 <dd><tt>cvs remove: Removing 3bits</tt></dd>
625 <dd><tt>…</tt></dd>
628 <dt>Explanation:</dt>
630 <dd>Schedules a file or directory for addition or removal
631 to/from the repository. The repository will not be changed
632 until the user runs <tt>cvs commit</tt>, except for the case of
633 adding a directory, which immediately changes the repository.
634 Also, directories cannot be truly removed from the repository,
635 just emptied out. (<tt>cvs update -P</tt> will prune empty
636 directories from your working copy.)</dd>
643 <dd><tt>$ touch foo.c</tt></dd>
644 <dd><tt>$ svn add foo.c</tt></dd>
645 <dd><tt>A foo.c</tt></dd>
646 <dd><tt> </tt></dd>
647 <dd><tt>$ mkdir new-dir</tt></dd>
648 <dd><tt>$ svn add new-dir</tt></dd>
649 <dd><tt>A new-dir</tt></dd>
650 <dd><tt> </tt></dd>
651 <dd><tt>$ svn rm bar.c</tt></dd>
652 <dd><tt>D bar.c</tt></dd>
653 <dd><tt> </tt></dd>
654 <dd><tt>$ svn rm old-dir</tt></dd>
655 <dd><tt>D old-dir/file1</tt></dd>
656 <dd><tt>D old-dir/file2</tt></dd>
657 <dd><tt>…</tt></dd>
659 <dt>Explanation:</dt>
661 <dd>Schedules a file or directory for addition or removal
662 to/from the repository. The repository will not be changed
663 until the user runs <tt>svn commit</tt>. The scheduled
664 operations are shown as <tt>A</tt> or <tt>D</tt> by <tt>svn
665 status</tt>, and <tt>svn revert</tt> can un-do the scheduling.
666 Directories really can be deleted (though as with all deleted
667 items, continues to exist in history.)</dd>
675 <dt>Book References:</dt>
676 <dd><a href="http://svnbook.red-bean.com/svnbook/ch03s05.html#svn-ch-3-sect-4.2">Make Changes to Your Working Copy</a></dd>
677 <dd><a href="http://svnbook.red-bean.com/svnbook/re01.html">svn add</a></dd>
678 <dd><a href="http://svnbook.red-bean.com/svnbook/re08.html">svn delete</a></dd>
683 <!-- ==================================================================== -->
685 <h2 id="copying">Copying and moving</h2>
687 <p>Copy or move/rename a file or directory.</p>
689 <table class="sidebyside">
698 <dd>(not possible.)</dd>
701 <dt>Explanation:</dt>
703 <dd>Not possible, unless an administrator directly mucks with
704 RCS files in the repository. (And in that case, no history
705 records the act of copying or renaming.)</dd>
712 <dd><tt>$ svn copy foo.c foo2.c</tt></dd>
713 <dd><tt>A foo2.c</tt></dd>
714 <dd><tt> </tt></dd>
715 <dd><tt>$ svn copy dir dir2</tt></dd>
716 <dd><tt>A dir2</tt></dd>
717 <dd><tt> </tt></dd>
718 <dd><tt>$ svn move bar.c baz.c</tt></dd>
719 <dd><tt>A baz.c</tt></dd>
720 <dd><tt>D bar.c</tt></dd>
721 <dd><tt> </tt></dd>
722 <dd><tt>$ svn move dirA dirB</tt></dd>
723 <dd><tt>A dirB</tt></dd>
724 <dd><tt>D dirA/file1</tt></dd>
725 <dd><tt>D dirA/file2</tt></dd>
726 <dd><tt>…</tt></dd>
728 <dt>Explanation:</dt>
730 <dd>The <tt>svn copy</tt> command schedules a file or directory
731 for addition to the repository, recording the "source" of the
732 copy. After committing, <tt>svn log</tt> on the copied item
733 will trace history back through the original copy-source. The
734 <tt>svn move</tt> command is exactly equivalent to running
735 <tt>svn copy</tt>, followed by an <tt>svn delete</tt> on the
736 copy-source: the result is a new item scheduled for addition
737 (with copy-history attached) and the original item scheduled for
746 <dt>Book References:</dt>
747 <dd><a href="http://svnbook.red-bean.com/svnbook/ch03s05.html#svn-ch-3-sect-4.2">Make Changes to Your Working Copy</a></dd>
748 <dd><a href="http://svnbook.red-bean.com/svnbook/re07.html">svn copy</a></dd>
749 <dd><a href="http://svnbook.red-bean.com/svnbook/re18.html">svn move</a></dd>
755 <!-- ==================================================================== -->
757 <h2>Finding the beginning of a branch</h2>
759 <p>If you're attempting to merge an entire branch into another, you
760 need to compare the "root" and "tip" of the source branch, and then
761 merge those differences into a working copy of the target branch.
762 Obviously the "tip" of the branch can be represented by using the
763 <tt>HEAD</tt> keyword. But how do you find the "birth" revision of
764 the source branch?</p>
766 <p>The easiest solution is to run</p>
769 $ svn log -v --stop-on-copy source-branch-URL
773 <p>This command will display every change ever made to the branch, but
774 <tt>--stop-on-copy</tt> option will cause the output to stop as soon
775 as detects a copy operation in the branch's history. By definition,
776 then, the very last log entry printed will show the copy being made.
777 It will look something like:</p>
780 r9189 | joe | 2004-03-22 10:10:47 -0600 (Mon, 22 Mar 2004) | 1 line
782 A /branches/mybranch (from /trunk:9188)
785 <p>In this case, you would then know to compare revisions 9189 and
786 HEAD of the branch in order to perform the merge:</p>
789 $ svn merge -r9189:HEAD source-branch-URL target-branch-WC
795 <!-- ==================================================================== -->
797 <h2>Seeing all of a project's tags</h2>
799 <p>Assuming you've been following a consistent policy for creating
800 tag-copies, then this is just a matter of running <tt>svn ls</tt> on a
801 directory containing your tags. Typically you would run it on the
802 <tt>/tags</tt> directory in your repository, although you're certainly
803 free to organize this directory in a more complex way, or invent a
804 different convention altogether.</p>
806 <p>As an example, you can see all of Subversion's tags by running:</p>
809 $ svn ls --verbose http://svn.apache.org/repos/asf/subversion/tags
811 7739 kfogel Nov 13 22:05 0.33.0/
812 7796 josander Nov 18 12:15 0.33.1/
813 7932 josander Dec 03 17:54 0.34.0/
814 8045 josander Dec 19 15:13 0.35.0/
815 8063 josander Dec 20 11:20 0.35.1/
816 8282 josander Jan 13 14:15 0.36.0/
817 8512 josander Jan 24 17:31 0.37.0/
818 8810 kfogel Feb 23 03:44 1.0.0/
824 <!-- ==================================================================== -->
826 <h2>Seeing the differences between two tags</h2>
828 <p>Just use <tt>svn diff</tt> in its fully expanded form, which
829 compares any two URLs:</p>
832 $ svn diff tagURL1 tagURL2
838 <!-- ==================================================================== -->
840 <h2>Seeing logs between two tags</h2>
842 <p>This is a somewhat common practice in CVS, and is doable in Subversion,
843 but requires a little bit more work. Assuming that you've made two
844 tags of <tt>/trunk</tt> at different points in time, the ultimate goal
848 $ svn log -rX:Y trunkURL
851 <p>…where X and Y are the revisions from which the two tags were
852 copied. To discover X and Y, you can use the same technique
853 described in the previous section ("finding the beginning of a
854 branch".) Just use the <tt>--stop-on-copy</tt> option when logging the
855 history of each tag. No commits happen on tag directories, so the
856 following commands should each produce exactly <em>one</em> log
860 $ svn log -v --stop-on-copy tag1-URL
862 r3520 | joe | 2004-03-12 15:28:43 -0600 (Fri, 12 Mar 2004) | 1 line
865 $ svn log -v --stop-on-copy tag2-URL
867 r4177 | joe | 2004-03-12 15:28:43 -0600 (Fri, 12 Mar 2004) | 1 line
871 <p>So in this example, the values of X and Y are 3520 and 4177. Now
872 you can view all <tt>/trunk</tt> changes between those two points in time:</p>
875 $ svn log -r3520:4177 trunkURL
881 <!-- ==================================================================== -->
883 <h2>Fixing an incorrect tag</h2>
885 <p>If your tag is a bit off, you can "adjust" it just as people often
886 do in CVS. Simply check out a working copy of the tag directory, make
887 any changes you wish, and commit.</p>
889 <p>Remember, because branches and tags are directories, they can also
890 be deleted when they're no longer of any use to your project. They'll
891 continue to exist in the repository's history.</p>
896 <!-- ==================================================================== -->
898 <h2>Creating/using "modules"</h2>
900 <p>Compare CVS Modules vs. svn:externals.</p>
904 <!-- ==================================================================== -->