【问题标题】:How do you rename a branch in CVS?如何重命名 CVS 中的分支?
【发布时间】:2009-07-10 06:47:42
【问题描述】:

如果您在 CVS 中错误地命名了一个分支,或者最初选择的名称变得不合适,您如何将其更改为其他名称?

一个相关的问题是How do you rename a branch in CVS without admin access?

【问题讨论】:

    标签: cvs


    【解决方案1】:

    解决这个问题的诀窍是使用 CVS 更晦涩的管理命令之一,-N。这是一个两阶段的过程,有效地复制然后删除。

    首先,您创建一个引用原始分支名称的正确名称的分支。其次,你删除了原来的分支名称。

    假设您有一个当前分支为“bad_branch”的文件“File.txt”。你想调用分支 - 你猜到了吗? - “好_branch”。

    kwutchak% cvs log File.txt

    RCS 文件:.../data/File.txt,v
    头:1.1
    分支:
    符号名称:
    _branch: 1.1.0.2

    创建新的分支引用:

    cvs admin -N good_branch:bad_branch File.txt
    

    kwutchak% cvs log File.txt

    RCS 文件:.../data/File.txt,v
    工作文件:File.txt
    头:1.1
    分支:
    符号名称:
    _branch: 1.1.0.2
    _branch: 1.1.0.2

    Bonus Tip:
    
    A symbolic name is not always required with `-N`.  It is sometimes
    valid to use a numeric reference to the branch (as when one may have
    used `cvs admin -N` and accidentally deleted the branch name by running 
    a delete command like `cvs admin -N bad_branch` when there is no
    other name assigned yet.  The following command worked to add a name
    to a branch (that contained only one file) and the file no longer had
    a branch name associated with it:
    
        cvs admin -N good_branch:1.1.2.1 File.txt
    

    删除原始参考:

    cvs admin -N bad_branch File.txt
    

    kwutchak% cvs log File.txt

    RCS 文件:.../data/File.txt,v
    工作文件:File.txt
    头:1.1
    分支:
    符号名称:
    _branch: 1.1.0.2

    【讨论】:

    • 请原谅我接受我自己的答案 - 我使用 StackOverflow 作为记录,这样我以后不需要再次研究这个......
    • 许多人出于相同的目的使用它,直到您为整个社区添加有用的东西,欢迎您这样做。
    【解决方案2】:

    由于我还不能将 cmets 添加到给定的答案中(信誉低),我想说明之前答案中的给定命令缺少双引号!

    更正:

    grep "old-branch-name" * -rl | xargs sed -i 's/old-branch-name/new-branch-name/g'
    

    【讨论】:

      【解决方案3】:

      如果你在“几个分支前”犯了一个错误,由于分支位置的变化,admin -N 选项将没有帮助。

      此解决方案仅适用于对您项目的存储库的完全访问权限。

      1. 转到 CVSROOT/项目
      2. 创建备份副本
      3. grep "旧分支名称" * -rl | xargs sed -i 's/old-branch-name/new-branch-name/g'

      对我来说就像一个魅力。

      抱歉,necro,但我认为我的解决方案将帮助任何与我的情况相似的人。

      【讨论】:

        猜你喜欢
        • 2022-08-09
        • 1970-01-01
        • 2012-03-20
        • 1970-01-01
        • 1970-01-01
        • 2016-07-08
        • 1970-01-01
        • 2011-09-29
        相关资源
        最近更新 更多