如何使用svn重命名文件? [英] How to rename a file using svn?

查看:135
本文介绍了如何使用svn重命名文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试 svn mv old_file_name new_file_name 时,我得到

When I try svn mv old_file_name new_file_name, I get

 svn: Path 'new_file_name' is not a directory

正确的方法是什么?(抱歉,这看起来很琐碎,但我被卡住了).

What's the correct way? (sorry, this seems so trivial, but I'm stuck).

附注.使用 svn 版本 1.6.11

PS. using svn version 1.6.11

EDIT 似乎只有当 new_file_name 引用当前受版本控制的文件的名称时,我才会收到此错误.在这种情况下,当然,我可以简单地

EDIT it seems I get this error only if new_file_name refers to the name of a file that is currently under version control. In this case, of course, I can simply

 mv old_file_name new_file_name
 svn delete old_file_name

推荐答案

行为因目标文件名是否已存在而异.这通常是一种安全机制,至少有 3 种不同的情况:

The behaviour differs depending on whether the target file name already exists or not. It's usually a safety mechanism, and there are at least 3 different cases:

在这种情况下 svn mv 应该如下工作:

In this case svn mv should work as follows:

$ svn mv old_file_name new_file_name
A         new_file_name
D         old_file_name
$ svn stat
A  +    new_file_name
        > moved from old_file_name
D       old_file_name
        > moved to new_file_name
$ svn commit
Adding     new_file_name
Deleting   old_file_name
Committing transaction...

存储库中已存在目标文件:

在这种情况下,需要明确删除目标文件,然后才能重命名源文件.这可以在同一个事务中完成,如下所示:

Target file already exists in repository:

In this case, the target file needs to be removed explicitly, before the source file can be renamed. This can be done in the same transaction as follows:

$ svn mv old_file_name new_file_name 
svn: E155010: Path 'new_file_name' is not a directory
$ svn rm new_file_name 
D         new_file_name
$ svn mv old_file_name new_file_name 
A         new_file_name
D         old_file_name
$ svn stat
R  +    new_file_name
        > moved from old_file_name
D       old_file_name
        > moved to new_file_name
$ svn commit
Replacing      new_file_name
Deleting       old_file_name
Committing transaction...

svn stat的输出中,R表示该文件已被替换,并且该文件有历史记录.

In the output of svn stat, the R indicates that the file has been replaced, and that the file has a history.

在这种情况下,本地文件的内容将会丢失.如果没问题,则可以在重命名现有文件之前在本地删除该文件.

In this case, the content of the local file would be lost. If that's okay, then the file can be removed locally before renaming the existing file.

$ svn mv old_file_name new_file_name 
svn: E155010: Path 'new_file_name' is not a directory
$ rm new_file_name 
$ svn mv old_file_name new_file_name 
A         new_file_name
D         old_file_name
$ svn stat
A  +    new_file_name
        > moved from old_file_name
D       old_file_name
        > moved to new_file_name
$ svn commit
Adding         new_file_name
Deleting       old_file_name
Committing transaction...

这篇关于如何使用svn重命名文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆