【发布时间】:2009-07-10 06:47:42
【问题描述】:
如果您在 CVS 中错误地命名了一个分支,或者最初选择的名称变得不合适,您如何将其更改为其他名称?
一个相关的问题是How do you rename a branch in CVS without admin access?。
【问题讨论】:
标签: cvs
如果您在 CVS 中错误地命名了一个分支,或者最初选择的名称变得不合适,您如何将其更改为其他名称?
一个相关的问题是How do you rename a branch in CVS without admin access?。
【问题讨论】:
标签: cvs
解决这个问题的诀窍是使用 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
【讨论】:
由于我还不能将 cmets 添加到给定的答案中(信誉低),我想说明之前答案中的给定命令缺少双引号!
更正:
grep "old-branch-name" * -rl | xargs sed -i 's/old-branch-name/new-branch-name/g'
【讨论】:
如果你在“几个分支前”犯了一个错误,由于分支位置的变化,admin -N 选项将没有帮助。
此解决方案仅适用于对您项目的存储库的完全访问权限。
对我来说就像一个魅力。
抱歉,necro,但我认为我的解决方案将帮助任何与我的情况相似的人。
【讨论】: