【问题标题】:git cvsimport fails: Could not merge master into the current branchgit cvsimport 失败:无法将 master 合并到当前分支
【发布时间】:2026-02-05 18:00:01
【问题描述】:

我正在尝试导入一个在 cvs 中增长了几年的项目。它有一些用于补丁发布、标签和头部的分支。 这是我正在使用的命令:

 git cvsimport -r cvs -k -d :pserver:<USERNAME>@cvs:/home/cvsroot <MODULNAME>

几周前它运行良好。几天前,为当前版本创建了一个分支,人们仍在提交,其他人已经在为下一个里程碑而努力。这个分支稍后会合并到head中。

该过程暂时失败,并显示以下消息:

fatal: Needed a single revision
fatal: Can merge only exactly one commit into empty head
Could not merge master into the current branch.

可能是什么原因?我该如何处理?

【问题讨论】:

    标签: git migration cvs


    【解决方案1】:

    我找到了一种解决方法,即不导入可追溯到 2006 年的整个历史记录。 这是我的程序:

    • 新建一个git仓库
    • 触摸一个新文件
    • 使用日期开关添加并提交该文件
    • 执行 cvs 导入

    以下是涉及的命令:

    mkdir project.cvs    
    mkdir project.git    
    cd project.git
    git init
    touch test
    git add test
    git commit -m "initial" --date="2010-01-01 00:00:00"
    cd ../project.cvs
    git cvsimport -o master -C ../project.git -k -d :pserver:<USERNAME>@cvs:/home/cvsroot <MODULENAME>
    

    就我而言,这需要一段时间,但当我改回 git 存储库时,可以使用 2010 年以来的历史记录。

    【讨论】:

      【解决方案2】:

      我发现这是可行的:

      $ cvs -d :pserver:anonymous@example.org:/path/to/cvsroot login
      $ git-cvsimport -v -a -i -k -d pserver:anonymous@example.org:/path/to/cvsroot -C <git_repository> <cvs_module>
      

      命令行参数是:

      -v: verbose; report a lot of information about what's going on
      -a: import all commits, not just recent ones
      -i: import-only. don't mess with working directory
      -k: 'kill keywords': no CVS keyword expansion (e.g. $Date$)
      -d: root of cvs archive (you could also set CVSROOT if you really wanted to)
      

      【讨论】:

        最近更新 更多