是否有从 CVS 到 Git 的迁移工具?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/881158/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 06:28:34  来源:igfitidea点击:

Is there a migration tool from CVS to Git?

gitversion-controlmigrationcvs

提问by freddiefujiwara

I intend to switch over from CVS to Git. In the case of SVN, there seems to be cvs2svn. Is there a similar tool to easily migrate from CVS to Git?

我打算从 CVS 切换到 Git。在 SVN 的情况下,似乎有cvs2svn. 有没有类似的工具可以轻松地从 CVS 迁移到 Git?

回答by Jakub Nar?bski

The only tool that has incrementalimport seems to be git-cvsimport. If you want to convert (migrate) from CVS to Git, the best solution for now seems to be mentioned above cvs2git mode of cvs2svn.

唯一具有增量导入的工具似乎是git-cvsimport。如果你想从 CVS转换(迁移)到 Git,目前最好的解决方案似乎是上面提到的cvs2svn 的 cvs2git 模式

See also Interfaces Frontends And Toolspage on Git wiki, section about interaction with other revision control systems.

另请参阅Git wiki 上的接口前端和工具页面,有关与其他修订控制系统交互的部分。

回答by Vanuan

cvs2git

cvs2git

In addition to provided answers, here's a guide on how to convert cvs to git using cvs2git tool. Here, modulename is a name of CVS directory you want to import.

除了提供的答案之外,这里还有一个关于如何使用 cvs2git 工具将 cvs 转换为 git 的指南。这里,modulename 是您要导入的 CVS 目录的名称。

Prerequisites

先决条件

cvs2svnpackage (which includes cvs2git command) should be already installed.

cvs2svn包(包括 cvs2git 命令)应该已经安装。

Update:steps 1 and 2 are not fully correct - before attempting, read the comment below by mhagger, the maintainer of cvs2git

更新:第1 步和第 2 步并不完全正确 - 在尝试之前,请阅读下面由 cvs2git 维护者 mhagger 撰写的评论

  1. checkout modulename

    cvs -d URL co -P modulename
    
  2. create an empty CVSROOT needed by cvs2git

    mkdir modulename/CVSROOT
    
  3. download an example of cvs2git.options at http://cvs2svn.tigris.org/svn/cvs2svn/trunk/cvs2git-example.options(user "guest" with no password)

  4. edit cvs2git.options file. Replace r'test-data/main-cvsrepos' with 'modulename'. Edit authors transforms.

    # edit this
    run_options.set_project(  r'modulename',
    
    # and this
    author_transforms={
        'jrandom' : ('J. Random', '[email protected]'),
        'mhagger' : 'Michael Haggerty <[email protected]>',
    
  5. run cvs2git to create git temp files

    cvs2git  --options=cvs2git.options --fallback-encoding utf-8
    
  6. create git repository

    mkdir gitrepo && cd gitrepo && git init .
    
  7. import from git temp files created by cvs2git

    cat ../cvs2git-tmp/git-{blob,dump}.dat | git fast-import
    
  8. checkout working copy

    git reset --hard
    
  1. 结帐模块名称

    cvs -d URL co -P modulename
    
  2. 创建一个 cvs2git 需要的空 CVSROOT

    mkdir modulename/CVSROOT
    
  3. http://cvs2svn.tigris.org/svn/cvs2svn/trunk/cvs2git-example.options下载 cvs2git.options 示例(用户“guest”,没有密码)

  4. 编辑 cvs2git.options 文件。将 r'test-data/main-cvsrepos' 替换为 'modulename'。编辑作者转换。

    # edit this
    run_options.set_project(  r'modulename',
    
    # and this
    author_transforms={
        'jrandom' : ('J. Random', '[email protected]'),
        'mhagger' : 'Michael Haggerty <[email protected]>',
    
  5. 运行 cvs2git 来创建 git 临时文件

    cvs2git  --options=cvs2git.options --fallback-encoding utf-8
    
  6. 创建 git 仓库

    mkdir gitrepo && cd gitrepo && git init .
    
  7. 从 cvs2git 创建的 git 临时文件导入

    cat ../cvs2git-tmp/git-{blob,dump}.dat | git fast-import
    
  8. 结帐工作副本

    git reset --hard
    

回答by bdonlan

cvs2svn has a cvs2gitmode.

cvs2svn 有一个cvs2git模式。

回答by user2603340

If anyone still has the misfortune of using CVS, you could try "crap" : https://github.com/rcls/crapIt's fast (as far as accessing CVS can be fast), supports the messes that you find in cvs repos, and incremental.

如果有人仍然有使用 CVS 的不幸,您可以尝试“废话”:https: //github.com/rcls/crap它很快(就访问 CVS 而言可以很快),支持您在 cvs repos 中找到的混乱, 和增量。

回答by ralphtheninja

An alternative might be to use git cvsimport *

另一种可能是使用git cvsimport *

回答by Dave W. Smith

I've not tried this myself, but friends have reported good success converting first from CVS to SVN, and then from SVN to Git. It seems that the tools to do those respective transitions have been more thoroughly shaken out than a direct CVS to Git transition.

我自己没有尝试过,但朋友们报告说,首先从 CVS 转换为 SVN,然后从 SVN 转换为 Git,非常成功。与直接从 CVS 到 Git 的转换相比,执行这些相应转换的工具似乎更彻底地被淘汰了。

回答by Tomek

I've tried cvs2git, git-cvsimport and parsecvs.

我试过 cvs2git、git-cvsimport 和 parsecvs。

cvs2git sometimes (as far as I remember) creates bogus branches for tags.

cvs2git 有时(据我所知)会为标签创建假分支。

git-cvsimport does not support multiple tags for a changeset. It is possible however to grab some additional changes for cvsps to support it and change the original git-cvsimport to something which uses updated cvsps (I've tried it and it seems to work). On the advantage side it supports incremental updates and has some logic to properly import merges (but it REQUIRES appropriate format for commit message).

git-cvsimport 不支持变更集的多个标签。然而,可以为 cvsps 获取一些额外的更改以支持它,并将原始 git-cvsimport 更改为使用更新的 cvsps 的内容(我已经尝试过,它似乎有效)。在优势方面,它支持增量更新并具有一些正确导入合并的逻辑(但它需要适当的提交消息格式)。

parsecvs so far gave me the best results. Unfortunately the code available on the web does not compile cleanly with the latest git. The change while not trivial is doable.

parsecvs 到目前为止给了我最好的结果。不幸的是,网络上可用的代码不能用最新的 git 干净利落地编译。虽然不是微不足道的改变是可行的。

EDIT: It looks like ESRtook over both cvspsand parsecvsso there is some hope for CVS->GIT migration. BUT he already mentioned on some mailing list that he may declare some of the tools he took over recently officially dead.

编辑:看起来ESR接管了cvspsparsecvs,所以CVS->GIT 迁移有一些希望。但是他已经在一些邮件列表中提到他可能会宣布他最近接管的一些工具正式死亡。

回答by robinr

You can add fromcvsto the list. It converts well and is extremely fast and also incremental. It does not do sticky tags, only branches, however.

您可以将fromcvs添加到列表中。它转换得很好,速度非常快,而且是增量的。然而,它不做粘性标签,只做分支。

回答by kenorb

You can use git cvsimport. It requires cvspsto be installed, but you need to install 2.x, as 3.x is not incompatibleanymore.

您可以使用git cvsimport. 它需要cvsps安装,但您需要安装 2.x,因为 3.x不再不兼容

Then import CVS repository on empty git. Sample usage:

然后在空的 git 上导入 CVS 存储库。示例用法:

git cvsimport -C RepoName -r cvs -o master -k -v -d:pserver:[email protected]:/cvsroot/path ModuleName


On OSX you install cvsps-2.1in the following way (having brew):

在 OSX 上,您cvsps-2.1按以下方式安装(有brew):

brew tap homebrew/versions
brew install cvsps2
brew link  cvsps2


You can also use cvs2gittool which can convert a CVS repository to git. However you need to have access to a CVSROOT directory.

您还可以使用cvs2git可以将 CVS 存储库转换为 git 的工具。但是,您需要有权访问 CVSROOT 目录。

Check cvs2git documentationfor installation steps.

检查cvs2git 文档以了解安装步骤。

Example usage:

用法示例:

cvs2git --blobfile=git-blob.dat --dumpfile=git-dump.dat --username=cvs2git /path/to/cvs/repo

This would create two output files in git fast-import format. The names of these files are specified by your options file or command-line arguments. In the example, these files are named cvs2git-tmp/git-blob.datand cvs2git-tmp/git-dump.dat.

这将创建两个 git fast-import 格式的输出文件。这些文件的名称由您的选项文件或命令行参数指定。在这个例子中,这些文件被命名为cvs2git-tmp/git-blob.datcvs2git-tmp/git-dump.dat

These files can be imported into empty git repository by:

这些文件可以通过以下方式导入到空的 git 存储库中:

cat git-blob.dat git-dump.dat | git fast-import

Then delete the TAG.FIXUPbranch and run gitk --allto view the results of the conversion.

然后删除TAG.FIXUP分支,运行gitk --all查看转换结果。

Check for more, by running: cvs2git --help.

检查多,运行:cvs2git --help

回答by josch

I read the answer by Vanuan and mhagger's comments to it. Unfortunately mhagger didn't post how to do it with cvs2git. It is all very well written up here: http://www.mcs.anl.gov/~jacob/cvs2svn/cvs2git.html

我阅读了 Vanuan 的回答和 mhagger 的评论。不幸的是,mhagger 没有发布如何使用cvs2git. 这里写得很好:http: //www.mcs.anl.gov/~jacob/cvs2svn/cvs2git.html

I used cvs2gitinstead of git-cvsimportbecause the documentation of git-cvsimportsuggests to use it instead to avoid the problems of git-cvsimport: https://www.kernel.org/pub/software/scm/git/docs/git-cvsimport.html#issues

我使用cvs2git而不是git-cvsimport因为文档git-cvsimport建议使用它来避免以下问题git-cvsimporthttps: //www.kernel.org/pub/software/scm/git/docs/git-cvsimport.html#issues

It follows essence of it that worked for me to create a git repository from a sourceforge CVS repository on Debian Sid:

它遵循它的本质,它对我有用,可以从 Debian Sid 上的 sourceforge CVS 存储库创建一个 git 存储库:

$ apt-get install cvs2svn cvs
$ mkdir project.cvs
$ rsync -av rsync://${PROJECT}.cvs.sourceforge.net/cvsroot/${PROJECT}/ project.cvs
$ cvs2git --blobfile=git-blob.dat --dumpfile=git-dump.dat --username=cvs2git project.cvs
$ mkdir project.git
$ cd project.git
$ git init
$ cat ../git-blob.dat ../git-dump.dat | git fast-import

The rsyncstep is needed because cvs2gitneeds access to the whole history. A simple checkout is not enough.

rsync步骤是必需的,因为cvs2git需要访问整个历史记录。简单的结账是不够的。