Update cvs2git.html.
[cvs2svn.git] / www / cvs2git.html
blob503a08a0284db3a991ca3f67dabf5407043c2a77
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <style type="text/css"> /* <![CDATA[ */
6 @import "tigris-branding/css/tigris.css";
7 @import "tigris-branding/css/inst.css";
8 /* ]]> */</style>
9 <link rel="stylesheet" type="text/css" media="print"
10 href="tigris-branding/css/print.css"/>
11 <script type="text/javascript" src="tigris-branding/scripts/tigris.js"></script>
12 <title>cvs2git Documentation</title>
13 </head>
15 <body id="bodycol">
16 <div class="app">
18 <h1>cvs2git</h1>
20 <h2>Index</h2>
22 <ul>
24 <li><a href="#intro">Introduction</a></li>
26 <li><a href="#reqs">Requirements</a></li>
28 <li><a href="#status">Development status</a></li>
30 <li><a href="#docs">Documentation</a></li>
32 <li><a href="#usage">Usage</a></li>
34 </ul>
36 <hr />
38 <h2><a name="intro">Introduction</a></h2>
40 <p>cvs2svn/cvs2git is a tool that can be used to migrate CVS
41 repositories to newer version control tools, including <a
42 href="http://git.or.cz/">git</a>. git is a distributed version
43 control system most famous for being used for Linux kernel
44 development. The program used to convert to git, called cvs2git, is
45 distributed as part of the cvs2svn project.</p>
47 <p><strong>If you are reading this documentation on the <a
48 href="http://cvs2svn.tigris.org">cvs2svn website</a>, then please be
49 aware that it describes the current trunk version of cvs2svn, which
50 may be different than the most recent released version. Please refer
51 to the documentation that was included with your version of cvs2svn.
52 </strong></p>
54 <p>Conversion to git was added in release 2.1 of cvs2svn and has
55 improved significantly since then. Please make sure you are using an
56 up-to-date version of cvs2svn--perhaps even the development trunk
57 version.</p>
60 <h2><a name="reqs">Requirements</a></h2>
62 <p>cvs2git requires the following:</p>
64 <ul>
66 <li>Direct (filesystem) access to a copy of the CVS repository that
67 you want to convert. cvs2git parses the files in the CVS
68 repository directly, so it is not enough to have remote CVS
69 access. See the <a href="faq.html#repoaccess">FAQ</a> for more
70 information and a possible workaround.</li>
72 <li>Python 2, version 2.4 or later. See <a
73 href="http://www.python.org/">http://www.python.org/</a>.
74 (cvs2git does <strong>not</strong> work with Python 3.x.)</li>
76 <li>If you use the <tt>--use-rcs</tt> option, then RCS's `co'
77 program is required. The RCS home page is
78 <a href="http://www.cs.purdue.edu/homes/trinkle/RCS/"
79 >http://www.cs.purdue.edu/homes/trinkle/RCS/</a>.
80 See the <a href="cvs2svn.html#use-rcs"><tt>--use-rcs</tt> flag</a> for more
81 details.</li>
83 <li>If you use the <tt>--use-cvs</tt> option, then the `cvs' command
84 is required. The CVS home page is
85 <a href="http://ccvs.cvshome.org/">http://ccvs.cvshome.org/</a>.
86 See the <a href="cvs2svn.html#use-cvs"><tt>--use-cvs</tt> flag</a> for more
87 details.</li>
89 <li> Git version 1.5.4.4 or later (earlier versions have a bug in
90 "git fast-import" that prevent them from loading the files
91 generated by cvs2git).</li>
93 </ul>
96 <h2><a name="status">Development status</a></h2>
98 <p>Most of the work of converting a repository from CVS to a more
99 modern version control system is inferring the most likely history
100 given the incomplete information that CVS records. cvs2svn has a long
101 history of making sense of even the most convoluted CVS repositories,
102 and cvs2git uses this same machinery. Therefore, cvs2git inherits the
103 robustness and many of the <a href="features.html">features of
104 cvs2svn</a>. cvs2svn can convert just about every CVS repository we
105 have ever seen, and includes a plethora of options for customizing
106 your conversion.</p>
108 <p>The output of cvs2git is one or more dump files that can be
109 imported into git using the excellent <a
110 href="http://www.kernel.org/pub/software/scm/git/docs/git
111 fast-import.html">git fast-import</a> tool.</p>
113 <p>Although cvs2git is considerably newer than cvs2svn, and much less
114 well tested, it is believed that cvs2git can be used for production
115 conversions. If you use cvs2git, please let us know how it worked for
116 you!</p>
119 <h2><a name="limitations">cvs2git limitations</a></h2>
121 <p>cvs2git still has many limitations compared to
122 cvs2svn. <strong>Help would be much appreciated!</strong> Some of
123 these missing features would be pretty easy to program, and I'd be
124 happy to help you get started.</p>
126 <ul>
128 <li>The cvs2git documentation is still not as complete as that for
129 cvs2svn. See <a href="#docs">below</a> for more references.</li>
131 <li>Differences between CVS and git branch/tag models: CVS allows a
132 branch or tag to be created from arbitrary combinations of source
133 revisions from multiple source branches. It even allows file
134 revisions that were never contemporaneous to be added to a single
135 branch/tag. Git, on the other hand, only allows the full source
136 tree, as it existed at some instant in the history, to be branched
137 or tagged as a unit. Moreover, the ancestry of a git revision
138 makes <a
139 href="http://softwareswirl.blogspot.com/2009/08/git-mercurial-and-bazaarsimplicity.html">implications
140 about the contents of that revision</a>. This difference means
141 that it is fundamentally impossible to represent an arbitrary CVS
142 history in a git repository 100% faithfully. cvs2git uses the
143 following workarounds:
145 <ul>
147 <li>cvs2git tries to create a branch from a single source, but
148 if it can't figure out how to, it creates the branch using a
149 "merge" from multiple source branches. In pathological
150 situations, the number of merge sources for a branch can be
151 arbitrarily large. The resulting history implies that
152 whenever any file was added to a branch, the <em>entire</em>
153 source branch was merged into the destination branch, which is
154 clearly incorrect. (The alternative, to omit the merge, would
155 discard the information that <em>some</em> content was moved
156 from one branch to the other.)</li>
158 <li>If cvs2git cannot determine that a CVS tag can be created
159 from a single revision, then it creates a <a
160 href="http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html">tag
161 fixup branch</a> named <tt>TAG.FIXUP</tt>, then tags this
162 branch. (This is a necessary workaround for the fact that git
163 only allows existing revisions to be tagged.) The
164 <tt>TAG.FIXUP</tt> branch is created as a merge between all of
165 the branches that contain file revisions included in the tag,
166 which involves the same tradeoff described above for branches.
167 The <tt>TAG.FIXUP</tt> branch is cleared at the end of the
168 conversion, but (due to a technical limitation of the git
169 fast-import file format) not deleted. There are some
170 situations when a tag <em>could</em> be created from a single
171 revision, but cvs2git does not realize it and creates a
172 superfluous tag fixup branch. It is possible to delete
173 superfluous tag fixup branches after the conversion by running
174 the <tt>contrib/git-move-refs.py</tt> script within the
175 resulting git repository.</li>
177 </ul>
179 </li>
181 <li>There are no checks that CVS branch and tag names are legal git
182 names. There are probably other git constraints that should also
183 be checked.</li>
185 <li>The data that should be fed to git fast-import are written to
186 two files, which have to be loaded into git fast-import manually.
187 These files might grow to very large size. It would be nice to
188 add an option to invoke git fast-import automatically and pipe the
189 output directly into git fast-import; this should also speed up
190 the conversion.</li>
192 <li>Only single projects can be converted at a time. Given the way
193 git is typically used, this is probably what you want anyway.</li>
195 <li>The cvs2svn test suite does not include meaningful tests of git
196 output.</li>
198 <li>cvs2git makes no attempt to convert <tt>.cvsignore</tt> files
199 into <tt>.gitignore</tt> files.</li>
201 <li>cvs2git, like cvs2svn, does not support incremental conversion
202 (i.e., tracking a live CVS repository). However, at least one
203 person has documented a <a
204 href="http://www.oak.homeunix.org/~marcel/blog/2009/06/03/tracking-cvs-with-git-using-cvs2git">possible
205 workaround</a>.</li>
207 </ul>
210 <h2><a name="docs">Documentation</a></h2>
212 <p>There is some documentation specific to cvs2git, and much of the
213 cvs2svn documentation also applies fairly straightforwardly to
214 cvs2git. See the following sources:</p>
216 <ul>
218 <li>This document.</li>
220 <li>The output of <tt>cvs2git --help</tt>.</li>
222 <li>The cvs2git man page. If the man page is not installed on your
223 Unix-like system, you can view it by typing a command like
224 <tt>cvs2git --man | groff -man -Tascii | less</tt>.</li>
226 <li><a href="cvs2svn.html#intro">The cvs2svn documentation</a> and
227 <a href="faq.html">the cvs2svn FAQ</a>, which contain much general
228 discussion and describe many features that can also be used for
229 cvs2git.</li>
231 <li><tt>cvs2git-example.options</tt> in the cvs2svn source tree,
232 which is an example of an options file that can be used to
233 configure a cvs2git conversion. The file is extensively
234 documented.</li>
236 <li>The cvs2svn mailing lists, IRC channel, etc., as described in <a
237 href="faq.html#gettinghelp">the cvs2svn FAQ</a>.</li>
239 </ul>
242 <h2><a name="usage">Usage</a></h2>
244 <p>This section outlines the steps needed to convert a CVS repository
245 to git using cvs2git.</p>
247 <ol>
249 <li>Be sure that you have the <a href="#reqs">requirements</a>,
250 including either RCS or CVS (used to read revision contents from
251 the CVS repository).</li>
253 <li>Obtain a copy of cvs2svn/cvs2git version 2.1 or newer. It is
254 recommended that you use the most recent version available, or
255 even the development version.
257 <ul>
259 <li>To install cvs2svn from a <a
260 href="http://cvs2svn.tigris.org/servlets/ProjectDocumentList">tarball</a>,
261 simply unpack the tarball into a directory on your conversion
262 computer; cvs2git can be run directly from this
263 directory.</li>
265 <li>
267 <p>To check out the current trunk version of cvs2svn, make
268 sure that you have Subversion installed and then run:</p>
270 <pre>
271 svn co --username=guest --password="" http://cvs2svn.tigris.org/svn/cvs2svn/trunk cvs2svn-trunk
272 cd cvs2svn-trunk
273 make man # If you want to create manpages for the main programs
274 make check # ...optional
275 </pre>
277 <p>Please note that the test suite includes tests that are
278 marked "XFAIL" (expected failure); these are known and are
279 not considered serious problems.</p>
281 </li>
283 </ul>
285 </li>
287 <li>
289 Configure cvs2git and run the conversion. This can be done via
290 command-line options or via an options file:
292 <ul>
294 <li>
296 <p>The command-line options for running cvs2git are documented
297 in the cvs2git man page and in the output of <tt>cvs2git
298 --help</tt>. For example:</p>
300 <pre>
301 cvs2git \
302 --blobfile=cvs2git-tmp/git-blob.dat \
303 --dumpfile=cvs2git-tmp/git-dump.dat \
304 --username=cvs2git \
305 /path/to/cvs/repo
306 </pre>
308 </li>
310 <li>
312 <p>The more flexible <a
313 href="cvs2svn.html#cmd-vs-options">options-file method</a>
314 requires you to create an options file, then start cvs2git
315 with</p>
317 <pre>
318 cvs2git --options=OPTIONS-FILE
319 </pre>
321 <p>Use <tt>cvs2git-example.options</tt> in the cvs2svn source
322 tree as your starting point; the file contains lots of
323 documentation.</p>
325 </li>
327 </ul>
329 <p>This creates two output files
330 in <a href="http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html">git
331 fast-import</a> format. The names of these files are specified
332 by your options file or command-line arguments. In the example,
333 these files are named <tt>cvs2git-tmp/git-blob.dat</tt> and
334 <tt>cvs2git-tmp/git-dump.dat</tt>.</p>
336 </li>
338 <li>
340 <p>Initialize a git repository:</p>
342 <pre>
343 git init --bare /path/to/myproject.git
344 cd /path/to/myproject.git
345 </pre>
347 </li>
349 <li>
351 <p>Load the dump files into the new git repository using <tt>git
352 fast-import</tt>:</p>
354 <pre>
355 git fast-import --export-marks=../cvs2git-tmp/git-marks.dat &lt;../cvs2git-tmp/git-blob.dat
356 git fast-import --import-marks=../cvs2git-tmp/git-marks.dat &lt;../cvs2git-tmp/git-dump.dat
357 </pre>
359 <p>On Linux/Unix this can be shortened to:</p>
361 <pre>
362 cat ../cvs2git-tmp/git-blob.dat ../cvs2git-tmp/git-dump.dat | git fast-import
363 </pre>
365 </li>
367 <li>
369 <p>Delete the <tt>TAG.FIXUP</tt> branch:</p>
371 <pre>
372 git branch -D TAG.FIXUP
373 </pre>
375 </li>
377 <li>
379 <p>(Optional) View the results of the conversion, for example:</p>
381 <pre>
382 gitk --all
383 </pre>
385 </li>
387 <li>(Recommended) To get rid of unnecessary tag fixup branches, run
388 the <tt>contrib/git-move-refs.py</tt> script from within the git
389 repository.</li>
391 <li>
393 <p>(Recommended) Re-compact the repository and discard any
394 garbage:</p>
396 <pre>
397 git gc --prune=now
398 </pre>
400 </li>
402 <li>
404 <p>The result of the above procedure is a <em>bare</em> git
405 repository (one that does not have a checked-out version of the
406 source tree). This is the type of repository that you would put
407 on your server. To work on your project, make a non-bare clone
408 (one that includes a checked-out source tree):</p>
410 <pre>
411 cd $HOME
412 git clone /path/to/myproject.git
413 cd myproject
414 </pre>
416 <p>Now you are ready to start editing files and committing to
417 git!</p>
419 </li>
421 </ol>
423 <h2><a name="non-bare">Converting to a non-bare repository</a></h2>
425 <p>If you want to convert into a non-bare git repository (one
426 that includes a working tree), then you need to make two changes to
427 the above procedure:</p>
429 <ul>
431 <li><p>Omit the <tt>--bare</tt> option in step 4; i.e., type</p>
433 <pre>
434 git init /path/to/myproject.git
435 cd /path/to/myproject.git
436 </pre>
438 </li>
440 <li><p>When the conversion is done, instead of cloning as described
441 in step 10, you need to explicitly check out the "master" version
442 of the files into your working tree:</p>
444 <pre>
445 git checkout master
446 </pre>
448 </li>
450 </ul>
452 <p>Feedback would be much appreciated, including reports of success
453 using cvs2git. Please send comments, bug reports, and patches to
454 the <a
455 href="http://cvs2svn.tigris.org/servlets/ProjectMailingListList">cvs2svn
456 mailing lists</a>.</p>
458 </div>
459 </body>
460 </html>