我无意中用svn del --targets del.txt删除了一个svn文件。现在,我想用svn cat myPreciousFile.txt@4130 > myPreciousFile.txt恢复这个文件,但是svn给了我一个警告,myPreciousFile.txt不在版本控制之下。svn cat -r 4130 myPreciousFile.txt > myPreciousFile.txt也不起作用。
有人能告诉我怎么再恢复这个文件吗?
编辑
好吧,我已经在svn merge上试过了,但还是不能用。以下是我所做的(为了保护罪犯而更改的文件名):
f:\path\to\dev\dir> svn diff -r 4250:4251 --summarize
D file_one.tyb
D file_two.tyb
D myPreciousFile.txt我将此输出解释为"myPreciousFile在第4251版中被删除“。所以,我和svn merge试过了
f:\path\to\dev\dir> svn merge-c -4251 myPreciousFile.txtsvn仍然警告我myPreciousFile.txt不在版本控制之下。(与svn merge-c -4250 myPreciousFile.txt相同的错误消息)。
发布于 2010-05-20 12:39:48
您不能用cat还原文件。
正确的方法是copy
svn copy http://server/full/path/to/myPreciousFile.txt@4130 .然后提交当前目录。使用此解决方案,您将保留该文件更改的完整历史记录。
发布于 2010-05-20 12:13:35
svn merge -c -<revision where you deleted the file> .因此,如果删除发生在第4131版期间,您将:
svn merge -c -4131 .
^ the negative on the revision is important针对这一问题,编辑:
您不应该指定文件名。只需执行.,您的文件就会被恢复。然后svn revert您不希望返回的更改。
发布于 2010-05-20 19:44:16
正如其他人所建议的那样,您可以进行反向合并以获取文件。我怀疑您的命令失败了,因为您还指定了要合并的特定文件,并且该文件不再受源代码管理。我可以看到两种方法来恢复它。
合并和还原
反向合并整个提交,然后还原您真正想要删除的文件。下面是你给出的例子:
f:\path\to\dev\dir> svn diff -r 4250:4251 --summarize
D file_one.tyb
D file_two.tyb
D myPreciousFile.txt进行反向合并:
f:\path\to\dev\dir> svn merge -c -4251然后还原真正要删除的两个:
f:\path\to\dev\dir> svn revert file_one.tyb
f:\path\to\dev\dir> svn revert file_two.tyb复制
使用zerkms建议的copy命令从存储库历史记录中复制您想要的特定文件。
svn copy http://server/full/path/to/myPreciousFile.txt@4130 .https://stackoverflow.com/questions/2873478
复制相似问题