是否有从 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
Is there a migration tool from CVS to Git?
提问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
先决条件
cvs2svn
package (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 撰写的评论
checkout modulename
cvs -d URL co -P modulename
create an empty CVSROOT needed by cvs2git
mkdir modulename/CVSROOT
download an example of cvs2git.options at http://cvs2svn.tigris.org/svn/cvs2svn/trunk/cvs2git-example.options(user "guest" with no password)
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]>',
run cvs2git to create git temp files
cvs2git --options=cvs2git.options --fallback-encoding utf-8
create git repository
mkdir gitrepo && cd gitrepo && git init .
import from git temp files created by cvs2git
cat ../cvs2git-tmp/git-{blob,dump}.dat | git fast-import
checkout working copy
git reset --hard
结帐模块名称
cvs -d URL co -P modulename
创建一个 cvs2git 需要的空 CVSROOT
mkdir modulename/CVSROOT
在http://cvs2svn.tigris.org/svn/cvs2svn/trunk/cvs2git-example.options下载 cvs2git.options 示例(用户“guest”,没有密码)
编辑 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]>',
运行 cvs2git 来创建 git 临时文件
cvs2git --options=cvs2git.options --fallback-encoding utf-8
创建 git 仓库
mkdir gitrepo && cd gitrepo && git init .
从 cvs2git 创建的 git 临时文件导入
cat ../cvs2git-tmp/git-{blob,dump}.dat | git fast-import
结帐工作副本
git reset --hard
回答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接管了cvsps和parsecvs,所以CVS->GIT 迁移有一些希望。但是他已经在一些邮件列表中提到他可能会宣布他最近接管的一些工具正式死亡。
回答by robinr
回答by kenorb
You can use git cvsimport
. It requires cvsps
to 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.1
in the following way (having brew
):
在 OSX 上,您cvsps-2.1
按以下方式安装(有brew
):
brew tap homebrew/versions
brew install cvsps2
brew link cvsps2
You can also use cvs2git
tool 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.dat
and cvs2git-tmp/git-dump.dat
.
这将创建两个 git fast-import 格式的输出文件。这些文件的名称由您的选项文件或命令行参数指定。在这个例子中,这些文件被命名为cvs2git-tmp/git-blob.dat
和cvs2git-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.FIXUP
branch and run gitk --all
to 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 cvs2git
instead of git-cvsimport
because the documentation of git-cvsimport
suggests 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-cvsimport
:https: //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 rsync
step is needed because cvs2git
needs access to the whole history. A simple checkout is not enough.
该rsync
步骤是必需的,因为cvs2git
需要访问整个历史记录。简单的结账是不够的。