简体   繁体   English

如何撤消svn中文件的删除

[英]How to undo removal of a file in svn

duplicate : What's a simple way to undelete a file in subversion? 复制在subversion中取消删除文件的简单方法是什么?


What is the best way to undo removal of a file and keep the file history. 撤消删除文件并保留文件历史记录的最佳方法是什么。

I've removed a file by accident, and commited it along with other changes. 我偶然删除了一个文件,并将其与其他更改一起提交。

I can get an older revision of the file and add it to svn, but I think this approach will lose change history. 我可以获得该文件的旧版本并将其添加到svn,但我认为这种方法将失去更改历史记录。

How do I keep the history? 我如何保留历史?

I can get an older revision of the file and add it to svn, but I think this approach will lose change history 我可以获得该文件的旧版本并将其添加到svn,但我认为这种方法将失去更改历史记录

No, it won't. 不,它不会。 This is the right thing to do. 这是正确的做法。 The history will reflect the removal of the file, but also its addition in the subsequent revision. 历史记录将反映文件的删除,但也会在后续修订中添加。 This is what history is -- a record of what happened. 这就是历史 - 记录发生的事情。

You could try a reverse merge, but if it's a single file, svn copy might be easier: 您可以尝试反向合并,但如果它是单个文件,则svn副本可能更容易:

svn copy file:///var/svn/repos/test/far-away -r 6 near-here

(Search that page for 'recommended') (在“推荐”中搜索该页面)

If you remove a file using TortiseSVN's delete menu command or svn rm , the history is still there. 如果使用TortiseSVN的删除菜单命令或svn rm删除文件,则历史记录仍然存在。 It is not lost unless you mess with the repository more deeply than that. 除非你更深入地了解存储库,否则它不会丢失。

Revert that file to an earlier revision. 将该文件还原为早期版本。

In TortoiseSVN, the easiest way to do this via the Log window. 在TortoiseSVN中,通过Log窗口执行此操作的最简单方法。

  • Right click on your working copy 右键单击您的工作副本
  • Click on Show Log 单击“ 显示日志”
  • Select the revision you deleted the file on 选择您删除文件的修订版本
  • Right click on the deleted file in the bottom pane 右键单击底部窗格中的已删除文件
  • Click on Revert changes from this revision 单击“ 从此修订版还原更改”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM