从SVN恢复已删除文件的正确方法是什么? [英] What is the correct way to restore a deleted file from SVN?

查看:78
本文介绍了从SVN恢复已删除文件的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从仓库中删除了一个文件,现在想把它放回去.我能想到的最好方法是:

I deleted a file from a repo and now want to put it back. The best I can figure out is to:

  • 更新到删除前的修订版
  • 将文件复制到别处
  • 更新到头
  • 复制文件
  • 添加它们
  • 提交

那只是闻起来很糟糕,并且会丢失所有历史记录.必须有更好的方法来做到这一点.我已经查看了 The SVN Book 但没有找到任何东西,现在正在查看 SVN 标签列表.

That just smells bad and it looses all history to boot. There has got to be a better way to do this. I have already looked in The SVN Book but didn't find anything and am now looking down the SVN tag list.

推荐答案

使用 svn merge:

Use svn merge:

svn merge -c -[rev num that deleted the file] http://<path to repository>

举个例子:

svn merge -c -12345 https://svn.mysite.com/svn/repo/project/trunk
             ^ The negative is important

对于 TortoiseSVN(我认为...)

For TortoiseSVN (I think...)

  • 在资源管理器中右键单击,转到 TortoiseSVN -> 合并...
  • 确保选中合并一系列修订",点击下一步
  • 在要合并的修订版范围"文本框中,指定删除文件的修订版
  • 选中反向合并"复选框,点击下一步
  • 点击合并

然而,这完全未经测试.

That is completely untested, however.

由 OP 编辑​​:这适用于我的 TortoiseSVN 版本(没有下一步按钮的旧版本)

Edited by OP: This works on my version of TortoiseSVN (the old kind without the next button)

  • 转到删除内容的文件夹
  • 在资源管理器中右键单击,转到 TortoiseSVN -> 合并...
  • From 部分输入删除的修订版
  • 部分输入删除前的修订版本.
  • 点击合并"
  • 提交
  • Go to the folder that stuff was delated from
  • Right click in Explorer, go to TortoiseSVN -> Merge...
  • in the From section enter the revision that did the delete
  • in the To section enter the revision before the delete.
  • Click "merge"
  • commit

诀窍是向后合并.感谢 sean.bright 为我指明了正确的方向!

The trick is to merge backwards. Kudos to sean.bright for pointing me in the right direction!

我们使用不同的版本.我描述的方法与我的 TortoiseSVN 版本完美配合.

We are using different versions. The method I described worked perfectly with my version of TortoiseSVN.

另外值得注意的是,如果您要反向合并的提交中有多个更改,则在您提交之前合并完成后,您将需要还原那些其他更改.如果您不这样做,这些额外的更改也将被撤销.

Also of note is that if there were multiple changes in the commit you are reverse merging, you'll want to revert those other changes once the merge is done before you commit. If you don't, those extra changes will also be reversed.

这篇关于从SVN恢复已删除文件的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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