问题描述
如果我在 Subversion 中删除了一个文件,我如何查看它的历史和内容?如果我尝试对不存在的文件执行 svn cat
或 svn log
,它会抱怨该文件不存在.
If I delete a file in Subversion, how can I look at it's history and contents? If I try to do svn cat
or svn log
on a nonexistent file, it complains that the file doesn't exist.
另外,如果我想恢复文件,我应该svn add
把它放回去吗?
Also, if I wanted to resurrect the file, should I just svn add
it back?
(我专门询问了 Subversion,但我也想了解 Bazaar、Mercurial 和 Git 如何处理这种情况.)
(I asked specifically about Subversion, but I'd also like to hear about how Bazaar, Mercurial, and Git handle this case, too.)
推荐答案
要获取已删除文件的日志,请使用
To get the log of a deleted file, use
svn log -r lastrevisionthefileexisted
如果您想恢复文件并保留其版本历史,请使用
If you want to resurrect the file and keep its version history, use
svn copy url/of/file@lastrevisionthefileexisted -r lastrevisionthefileexisted path/to/workingcopy/file
如果您只想要文件内容但没有版本化(例如,为了快速检查),请使用
If you just want the file content but unversioned (e.g., for a quick inspection), use
svn cat url/of/file@lastrevisionthefileexisted -r latrevisionthefileexisted > file
无论如何,不要使用svn up"来恢复被删除的文件!
In any case, DO NOT use 'svn up' to get a deleted file back!
这篇关于检查已删除文件的历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!