Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在CVS中恢复已删除的文件?_Cvs - Fatal编程技术网

如何在CVS中恢复已删除的文件?

如何在CVS中恢复已删除的文件?,cvs,Cvs,我已从CVS分支中删除签入文件,即: cvs remove -f file.txt cvs commit 如何恢复该文件?我认为: cvs add file.txt cvs commit file.txt 。。。将从阁楼上恢复它。我发现您不能使用cvs add撤消已提交的cvs remove操作。所以这是可行的: $ cvs remove -f file.txt $ cvs add file.txt 但这不起作用: $ cvs remove -f file.txt $ cvs commit

我已从CVS分支中删除签入文件,即:

cvs remove -f file.txt
cvs commit
如何恢复该文件?

我认为:

cvs add file.txt
cvs commit file.txt

。。。将从阁楼上恢复它。

我发现您不能使用
cvs add
撤消已提交的
cvs remove
操作。所以这是可行的:

$ cvs remove -f file.txt
$ cvs add file.txt
但这不起作用:

$ cvs remove -f file.txt
$ cvs commit
$ cvs add file.txt

到目前为止,我找到的最简单的方法是运行
cvs status file.txt
来查找修订号。然后抓取修订内容并将其添加回:

$ cvs update -p -r rev file.txt > file.txt
$ cvs add file.txt
$ cvs commit

鉴于Harry缺乏成功,以下是我为证明上述答案有效所做的一份记录(对其篇幅提前表示歉意):

C:\foo>dir
驱动器C中的卷是本地磁盘
卷序列号为344F-1517
C:\foo目录
2008年9月28日下午5:12。
2008年9月28日下午5:12。。
2008年9月28日下午5:12
28/09/2008 05:11 PM 19 file.txt
1个文件19字节
3个目录22686416896个可用字节
C:\foo>cvs状态文件.txt
===================================================================
文件:File.txt状态:最新
工作修订:1.2星期日2008年9月28日07:11:58
存储库修订版:1.2c:\jason\CVSROOT/foo/file.txt,v
粘性标签:(无)
粘性日期:(无)
粘性选项:(无)
C:\foo>cvs rm-f file.txt
cvs remove:计划删除'file.txt'
cvs删除:使用“cvs提交”永久删除此文件
C:\foo>cvs提交-m“file.txt
删除file.txt文件;
C:\jason\CVSROOT/foo/file.txt,v cvs status file.txt
===================================================================
文件:无文件File.txt状态:最新
工作版本:file.txt没有条目
存储库修订版:1.3 C:\jason\CVSROOT/foo/Attic/file.txt,v
C:\foo>more file.txt
无法访问文件C:\foo\file.txt
C:\foo>dir
驱动器C中的卷是本地磁盘
卷序列号为344F-1517
C:\foo目录
2008年9月28日下午5:12。
2008年9月28日下午5:12。。
2008年9月28日下午5:12
0个文件0个字节
3个目录22686400512字节可用
C:\foo>cvs add file.txt
cvs添加:从修订版1.2中恢复文件'file.txt'。
U文件.txt
cvs添加:重新添加文件“file.txt”(代替旧版本1.3)。
cvs添加:使用“cvs提交”永久添加此文件
C:\foo>cvs提交-m“file.txt
签入file.txt文件;
C:\jason\CVSROOT/foo/file.txt,v more file.txt
这是一个测试。。。
C:\jason\work\dev1\nrta\foo>dir
驱动器C中的卷是本地磁盘
卷序列号为344F-1517
C:\jason\foo目录
2008年9月28日下午5:15。
2008年9月28日下午5:15。。
2008年9月28日下午5:13
28/09/2008 05:13 PM 19 file.txt
1个文件19字节
3 Dir(s)22686375936可用字节

显然他做的是对的,但他观察到的行为是不同的。可能是因为CVS版本不同(我在Windows上使用的是1.11.22)。

CVS添加对我不起作用,因为我在服务器上的CVS版本非常旧。我已经确认,它在CVS版本1.11.22上运行良好。

下面是我的工作。我只是创建一个同名的空文件,然后添加并提交它,然后检索旧版本并重新提交。

尝试:

cvs add file.txt
cvs update file.txt
cvs commit file.txt

cd进入$CVSROOT目录和相关模块目录,然后进入阁楼, 编辑fileOfInterest,v并更改显示为Dead的行;Exp;然后将fileOfInterest,v移动到上面的目录


签出模块中的更新现在将恢复该文件。

最简单但可能最不优雅的方法是将其“cd”到CVS目录中与删除的文件相同的位置

然后编辑名为“条目”的文件

查找表示已删除文件的行。请注意,在/

删除“-”,保存文件,瞧


不好,但它起作用了。

我很高兴我们找到了问题的根源,哈利。我有点担心了。:-)感谢Jason花时间提供了详细的回复。忘记了文件的最后修订版了吗?cvs日志[文件名]
cvs add file.txt
cvs update file.txt
cvs commit file.txt