SVN:您能否仅从本地结帐(而不是从存储库)中删除目录? [英] SVN: Can you remove directories from a local checkout only (not from the repository)?

查看:25
本文介绍了SVN:您能否仅从本地结帐(而不是从存储库)中删除目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您有一个受 subversion 控制的目录,其中包含一些文件和大量子目录,例如:

Assume that you have a directory under subversion control, that contains some files and tons of subdirectories, like that:

file1.txt
file2.txt
file3.txt
dir1/
dir2/
dir3/
dir4/
:
dirXX/

现在您需要文件和一些目录,但不是全部.这可以通过 SVN 来完成.只需使结帐非递归:

Now you need the files and some of the dirs, but not all of them. This can be done with SVN. Just make the checkout non-recursive:

svn checkout -N <URL>

这只会检查第一个目录和里面的文件.不包含子目录.即使您进入检出目录并运行svn up",它也只会更新先前检出的文件,而不会添加目录.您现在可以通过显式更新这些目录来选择性地添加您需要的目录.例如.如果只需要dir2和dir4,可以进入checkout目录执行

This checks out only the first directory and the files inside. No subdirectories are included. Even if you go into the checkout directory and run a "svn up", it will only update the files checked out previously, it will not add the directories. You can now selectively add the directories you need by explicitly updating those. E.g. if you need dir2 and dir4 only, you can go into the checkout directory and execute

svn up dir2
svn up dir4

如果您以后运行通用的svn up",它只会更新文件和这两个目录,不会添加任何其他目录.

If you run a generic "svn up" in the future, it will only update the files and those two directories, it will not add any of the other directories.

现在的问题是:如果我以后决定不再需要 dir2 怎么办?我该如何摆脱它?似乎没有办法这样做,除了删除整个结帐并从头开始.

Now the problem: What if I decide at any later point that I don't need dir2 any longer? How do I get rid of it? There seems no way of doing so, other than deleting the whole checkout and start over from scratch.

当您刚刚删除 dir2 时,下一个svn up"会将其带回来,因为svn status"当然现在显示它已丢失(!"在它的名字前面).运行svn remove"当然会删除它,但在下一次提交时它也会将它从存储库中删除,这一定不会发生.

When you just delete dir2, the next "svn up" will bring it back, as "svn status" of course shows it as missing now ("!" in front of its name). Running a "svn remove" will remove it of course, but on next commit it will also remove it from the repository, which must not happen.

即使是 SVN 1.5 的新稀疏目录(浅检出")功能在这里也没有用处:

Even the new sparse directory ("shallow checkout") feature of SVN 1.5 is of no use here:

Subversion 1.5 的实现浅结账很好,但不是支持几个有趣的行为.首先,你不能取消伸缩工作副本项目.运行 svn update --set-depth 为空在无限深度的工作副本中没有丢弃的效果除了最上面的一切目录——它只会出错.
- http://svnbook.red-bean.com/en/1.5/svn.advanced.sparsedirs.html

Subversion 1.5's implementation of shallow checkouts is good but does not support a couple of interesting behaviors. First, you cannot de-telescope a working copy item. Running svn update --set-depth empty in an infinite-depth working copy will not have the effect of discarding everything but the topmost directory—it will simply error out.
- http://svnbook.red-bean.com/en/1.5/svn.advanced.sparsedirs.html

这对 SVN 来说是完全不可能的吗?有没有人想出一个聪明的解决方法?

Is this complete impossible with SVN? Anyone ever came up with a clever work-a-round to that?

只需创建检出目录(没有 SVN),然后直接从存储库检出各个子目录作为该目录的子目录将适用于这些目录:现在每个目录都是自己的检出,可以更新,一旦不更新不再需要,你可以删除它.但是,我如何获取文件(例如 file1.txt)?SVN 不允许检出单个文件,您只能检出整个目录.

Just creating the checkout directory (without SVN) and then checking out the individual subdirectories from the repository directly as subdirectories to this directory will work for the directories: now every directory is a checkout of its own, can be updated and once not needed any longer, you can just delete it. However, how do I get the files then (e.g. file1.txt)? SVN does not allow to checkout individual files, you can only checkout whole directories.

推荐答案

我想要做的事情在 Subversion 1.4 或 Subversion 1.5 中无法完成;期间.
没有解决方法,就是这样.

不过可以使用 Subversion 1.6 来完成.

与 SVN 1.5 不同,SVN 1.6 可以减少目录的深度

Unlike SVN 1.5, SVN 1.6 can reduce the depth on a directory

svn up --set-depth exclude dir2

是解决方案.它将 dir2 的深度设置为零,它将立即从结帐中消失,并且没有更新将其带回,除非您再次明确将此目录的深度设置为一个值(或者只是在没有深度选项的情况下对其进行更新,因为不给出任何深度总是意味着无穷大,除非你使用非递归,这​​意味着文件").

is the solution. It sets the depth for dir2 to zero and it will immediately vanish from the checkout and no update will bring it back, unless you explicitly set the depth of this directory to a value again (or just do an update on it without depth option, since not giving any depth always means infinity, unless you use non-recursive, which means "files").

提示:
实际上,SVN 1.6 并不能像增加深度那样真正减少深度.您可以将其从任何级别增加到任何更高级别.您只能将其减少为排除"(所有级别中的最低级别).如果您想从无穷大"(最高)减少到文件"(中间某处),您必须首先将其减少到排除"(导致目录消失),然后再将其增加回文件".这有点小技巧,但效果很好.

TIP:
Actually SVN 1.6 cannot really reduce the depth the same way it can increase it. You can increase it from any level to any higher level. You can only reduce it to "exclude" (the lowest level of all). If you want to reduce from "infinity" (highest) to "files" (somewhere in the middle), you must first reduce it to "exclude" (causing the directory to vanish) and then increase it back again to "files". This is a bit of a hack, but it works just nice.

这篇关于SVN:您能否仅从本地结帐(而不是从存储库)中删除目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆