如何告诉TortoiseSVN重命名的文件被重命名(不是删除并重新添加)?

发布于 08-20 07:54 字数 131 浏览 11 评论 0原文

这里使用 VisualSVN 和 TortoiseSVN。

我已经重命名了我的文件。我注意到它说添加和删除对我来说意味着历史记录可能会被删除?

在 Subversion 中重命名文件而不丢失历史记录的最佳方法是什么?

Using VisualSVN and TortoiseSVN here.

I've renamed my file. I notice it say add and delete which to me means history may be erased?

What is the best way to rename a file without losing history in Subversion?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

如此安好2024-08-27 07:54:59

历史记录不会被删除,但您将丢失历史记录跟踪,因为它似乎是两个不相关的文件。

来自 TortoiseSVN 文档

如果您想对文件或文件夹进行简单的就地重命名,请使用上下文菜单→重命名...输入项目的新名称即可完成。

修复文件重命名

有时,作为重构练习的一部分,您友好的 IDE 会为您重命名文件,当然它不会告诉 Subversion。如果您尝试提交更改,Subversion 会将旧文件名视为缺失,并将新文件视为未版本控制的文件。您可以只检查新文件名以将其添加到其中,但是您将丢失历史记录跟踪,因为 Subversion 不知道这些文件是相关的。

更好的方法是通知 Subversion 此更改实际上是重命名,您可以在“提交”和“检查修改”对话框中执行此操作。 只需选择旧名称(缺失)和新名称(未版本化),然后使用上下文菜单 → 修复移动将两个文件配对为重命名

还涵盖了许多其他案例。

更新

当 Subversion 不知道这是重命名时,历史记录就会丢失,如下所示:

  • 旧文件名为 aa.txt,然后手动将其重命名为 bb.txt
  • 新文件名 bb.txt 已添加到
  • 提交对话框中的 subversion,aa.txt 显示为缺失可以标记为已删除,而bb.txt则显示为已添加
  • 结果是历史记录丢失,SVN显示日志<上下文菜单中的 /strong> 将仅显示 bb.txt

要保留文件历史记录,您需要使用上下文菜单(或命令行)中的重命名选项。 如果您已经重命名了文件,那么:

  • 旧文件名 cc.txt 将显示为缺失,
  • 选中显示未版本控制的文件选项以查看新文件文件名 dd.txt,标记为非版本化
  • 选择两个文件名,然后从上下文菜单中选择修复移动,这会导致 cc.txt 被标记为已删除dd.txt 被标记为添加 (+)
  • 提交后,历史记录中 将被保留,并且如果取消选中复制/重命名时停止选项,您将在日志中看到两个文件名。

因此,要恢复,在提交对话框中添加(+)意味着将保留历史记录,添加意味着丢失历史记录。在这两种情况下,旧文件名都会显示为已删除

更新2

当我说历史丢失时,请理解以前的信息仍然存在,但它不会出现在当前文件名的日志中,你必须手动跟踪它(这这可不是一件令人愉快的事情)。

The history won't be erased, but you will lose history tracing, as it would seem to be two unrelated files.

From TortoiseSVN docs:

If you want to do a simple in-place rename of a file or folder, use Context Menu → Rename... Enter the new name for the item and you're done.

Repairing File Renames

Sometimes your friendly IDE will rename files for you as part of a refactoring exercise, and of course it doesn't tell Subversion. If you try to commit your changes, Subversion will see the old filename as missing and the new one as an unversioned file. You could just check the new filename to get it added in, but you would then lose the history tracing, as Subversion does not know the files are related.

A better way is to notify Subversion that this change is actually a rename, and you can do this within the Commit and Check for Modifications dialogs. Simply select both the old name (missing) and the new name (unversioned) and use Context Menu → Repair Move to pair the two files as a rename.

Many other cases are covered.

Update

The history is lost when Subversion doesn't know it's a rename, like this:

  • the old file name is aa.txt, and it's renamed by hand to bb.txt
  • the new file name bb.txt is added to subversion
  • in the commit dialog, aa.txt appears as missing and can be marked as deleted, and bb.txt appears as added
  • the result is that history is lost, SVN show log from the contextual menu will show only bb.txt

To preserve file history, you need to use the Rename option from the contextual menu (or from the command line). IF you already renamed the file then:

  • the old file name cc.txt will appear as missing
  • check the Show unversioned files option to see the new file name dd.txt, which is marked as non-versioned
  • select both file names and choose Repair move from the contextual menu, which results in cc.txt being marked as deleted and dd.txt being marked as added (+)
  • after commit, history will be preserved, and in the log you will see both file names if you uncheck the Stop on copy/rename option.

So, to resume, in the commit dialog added (+) means that history will be preserved, and added means loosing the the history. In both cases, the old file name will appear as deleted.

Update 2

When I say that history is lost, please understand that the previous information still exists, but it won't be present in the log of the current file name, and you must manually track it (which is not quite a pleasant thing to do).

ゝ杯具2024-08-27 07:54:59

右键单击文件>乌龟SVN>重命名。

Right Click on the file > TortoiseSVN > Rename.

只有一腔孤勇2024-08-27 07:54:59

从 TortoiseSVN 上下文菜单中进行重命名不会删除历史记录。如果您想查看重命名之前的更改,请确保在查看更改日志时不使用 --stop-on-copy 标志:

svn log -v -r 0:N --limit 100 [--stop-on-copy] PATH
  or
svn log -v -r M:N [--stop-on-copy] PATH

请参阅此处以供参考:
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-cli -main.html

The history is not erased by doing a rename from the TortoiseSVN Context Menu. If you want to see the changes from before the rename, make sure you don't use the --stop-on-copy flag when looking at the change log:

svn log -v -r 0:N --limit 100 [--stop-on-copy] PATH
  or
svn log -v -r M:N [--stop-on-copy] PATH

see here for reference:
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-cli-main.html

夏有森光若流苏2024-08-27 07:54:59

文件的历史记录不会被删除。之前的提交不会受到影响。但是,您可以使用 svn move 来正确移动文件。

The file's history will not be erased. Previous commits won't be affected. However, you can use svn move to properly move the file.

夏花。依旧2024-08-27 07:54:59

For file operations like moving and renaming I normally prefer to use the TortoiseSVN Repo Browser, followed by a local SVN Update. Of course that's only appropriate if you want your operation to be committed to the repository straight away.

仲春光2024-08-27 07:54:59

在 Subversion 中重命名文件时,预期会发生删除和添加历史记录的情况。历史并没有丢失。

VisualSvn 和 AnkhSvn 都从 Visual Studio 捕获文件被重命名的事件,并执行正确的操作。

A delete and add with history is the expected thing to happen when renaming a file in Subversion. History is not lost.

VisualSvn and AnkhSvn both capture the events from Visual Studio that a file is being renamed, and do the right thing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文