“不可能只签出一个文件。你能做的最好的签出级别是在目录级别。”

在使用Subversion时,我如何解决这个问题?

我们在Subversion中有这个文件夹,用来保存所有的图像。我只是想从其中找出一个文件(图像)。这个文件夹真的很大,里面有很多我现在不需要的东西。


当前回答

cd C:\path\dir
svn checkout https://server/path/to/trunk/dir/dir/parent_dir--depth empty
cd C:\path\dir\parent_dir
svn update filename.log

(编辑filename.log)

svn commit -m "this is a comment."

其他回答

我只需要浏览并导出单个文件。如果您有HTTP访问权限,只需使用web浏览器找到文件并获取它。

如果你在编辑后需要把它放回去,这可能会有点乏味,但我相信可能会有一个svn import函数……

If you want to view readme.txt in your repository without checking it out: $ svn cat http://svn.red-bean.com/repos/test/readme.txt This is a README file. You should read this. Tip: If your working copy is out of date (or you have local modifications) and you want to see the HEAD revision of a file in your working copy, svn cat will automatically fetch the HEAD revision when you give it a path: $ cat foo.c This file is in my local working copy and has changes that I've made. $ svn cat foo.c Latest revision fresh from the repository!

此问题由第823期“svn检出单个文件”覆盖,最初由Eric Gillespie[1]于2002年7月27日报道。

附带的Perl脚本[2]允许您从svn签出单个文件,进行更改,并将更改提交回存储库,但是不能运行“svn up”来签出目录的其余部分。它已经在svn-1.3、1.4和1.6上进行了测试。

注意,最初托管在tigris.org上的Subversion项目被转移到了apache.org。第823期的原始URL在tigris.org上,这个不存在的URL[3]。互联网档案时光倒流机有这个原始链接[4]的副本。

1 - https://issues.apache.org/jira/browse/SVN-823?issueNumber=823

2 - https://issues.apache.org/jira/secure/attachment/12762717/2_svn-co-one-file.txt

3 - http://subversion.tigris.org/issues/show_bug.cgi?id=823

4 - https://web.archive.org/web/20170401115732/http://subversion.tigris.org/issues/show_bug.cgi?id=823

史蒂夫·杰索普的回答对我不起作用。我读了SVN的帮助文件,如果你只有一张图片,你可能不想再签入它,除非你在使用Photoshop,所以导出是一个比签出更好的命令,因为它是未版本的(但这是次要的)。

——depth ARG不应该是空的而是获取直接目录中的文件。因此,您将获得所有字段,而不仅仅是一个,但empty不会从存储库中返回任何内容。

 svn co --depth files <source> <local dest>

or

svn export --depth files <source> <local dest>

至于其他答案,cat让你阅读的内容只适合文本,而不是所有东西的图像。

尝试svn export而不是svn checkout。这适用于单个文件。

限制的原因是签出创建了一个工作副本,其中包含关于存储库、修订、属性等的元信息。元数据存储在名为“.svn”的子目录中。单个文件没有子目录。