我已经从 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
这cvs add
对我不起作用,因为我在服务器上的 cvs 版本非常旧。我已经确认它适用于 CVS 1.11.22 版。
尝试:
cvs add file.txt
cvs update file.txt
cvs commit file.txt
鉴于哈利缺乏成功,这是我为证明上述答案有效而所做的成绩单(提前为它的长度道歉):
C:\foo>dir
Volume in drive C is Local Disk
Volume Serial Number is 344F-1517
Directory of C:\foo
28/09/2008 05:12 PM <DIR> .
28/09/2008 05:12 PM <DIR> ..
28/09/2008 05:12 PM <DIR> CVS
28/09/2008 05:11 PM 19 file.txt
1 File(s) 19 bytes
3 Dir(s) 22,686,416,896 bytes free
C:\foo>cvs status file.txt
===================================================================
File: file.txt Status: Up-to-date
Working revision: 1.2 Sun Sep 28 07:11:58 2008
Repository revision: 1.2 C:\jason\CVSROOT/foo/file.txt,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
C:\foo>cvs rm -f file.txt
cvs remove: scheduling `file.txt' for removal
cvs remove: use 'cvs commit' to remove this file permanently
C:\foo>cvs commit -m "" file.txt
Removing file.txt;
C:\jason\CVSROOT/foo/file.txt,v <-- file.txt
new revision: delete; previous revision: 1.2
done
C:\foo>cvs status file.txt
===================================================================
File: no file file.txt Status: Up-to-date
Working revision: No entry for file.txt
Repository revision: 1.3 C:\jason\CVSROOT/foo/Attic/file.txt,v
C:\foo>more file.txt
Cannot access file C:\foo\file.txt
C:\foo>dir
Volume in drive C is Local Disk
Volume Serial Number is 344F-1517
Directory of C:\foo
28/09/2008 05:12 PM <DIR> .
28/09/2008 05:12 PM <DIR> ..
28/09/2008 05:12 PM <DIR> CVS
0 File(s) 0 bytes
3 Dir(s) 22,686,400,512 bytes free
C:\foo>cvs add file.txt
cvs add: Resurrecting file `file.txt' from revision 1.2.
U file.txt
cvs add: Re-adding file `file.txt' (in place of dead revision 1.3).
cvs add: use 'cvs commit' to add this file permanently
C:\foo>cvs commit -m "" file.txt
Checking in file.txt;
C:\jason\CVSROOT/foo/file.txt,v <-- file.txt
new revision: 1.4; previous revision: 1.3
done
C:\foo>more file.txt
This is a test...
C:\jason\work\dev1\nrta\foo>dir
Volume in drive C is Local Disk
Volume Serial Number is 344F-1517
Directory of C:\jason\foo
28/09/2008 05:15 PM <DIR> .
28/09/2008 05:15 PM <DIR> ..
28/09/2008 05:13 PM <DIR> CVS
28/09/2008 05:13 PM 19 file.txt
1 File(s) 19 bytes
3 Dir(s) 22,686,375,936 bytes free
显然他在做正确的事,但他观察到的行为是不同的。由于 CVS 版本(我在 Windows 上使用 1.11.22),可能存在差异。
cd 进入 $CVSROOT 目录和相关模块目录,然后进入阁楼,编辑 fileOfInterest,v 并更改说 Dead 的行;到 Exp; 然后将 fileOfInterest,v 移动到上面的目录。
签出模块中的更新现在将恢复该文件。
最简单但最不优雅的方法是“cd”到 CVS 目录中与已删除文件相同的位置。
然后编辑名为“Entries”的文件。
找到代表您已删除文件的行。注意 / 后面有一个“-”
删除'-',保存文件,瞧!
糟糕,但它有效。
这就是我所做的。我只是创建一个同名的空文件,然后添加并提交它,然后检索旧版本并重新提交。