如何阻止 SVN 更新存储库中已有的目录

发布于 2024-07-13 07:13:26 字数 1062 浏览 12 评论 0 原文

我不认为这不是一个标准的 svn 忽略问题。

我有一个存储库,其中有一个我不想要的巨大目录。 因为其他人使用存储库这样做,所以我不能只是从树中删除它。 但是,我不想每次执行 svn up 时都重新下载该目录。 我可以理解,忽略将阻止我将目录上传到 svn,但是我如何告诉 svn 我不希望它重新下载存储库中已有的特定目录。

我做什么...

svn up
rm badDirectory

然后未来的 svn up 重新下载它。 我想阻止这种情况发生。

谢谢!

编辑:好的。 我希望 SVN 有一个我只是还没有注意到的内置选项。 我希望避免必须“破解”颠覆的不足之处,但下面的选项似乎是可以接受的替代方案。

再次编辑以解决一些评论:

有什么特别的原因让你 无法签出该文件夹并保留 它 ? 没有磁盘空间(可能不是因为 你可以检查一下)? 安全 原因?

我可以查看该文件夹。 整个 svn 存储库大约有 291 兆。其中 290 兆位于这个“坏”目录中。 基本上,其他一些控制存储库的人(因此可以决定其中的内容)在其中放置了一个实际上不需要的目录。 我并不是说这是一个关于政策和使用 svn 的“正确和正确”方式的问题。 我只是想知道是否有技术解决方案。

你能给出一个更好的描述吗? 存储库的树结构? 是否有同级别的文件 坏目录,或仅其他 目录? –

基本结构:

repository root
 - good dir 1
    - plenty of subdirs in all of these directories
 - good dir 2
 - good dir X
 - bad dir 1
 - bad dir 2
 - bad dir X 
 - good file 1
 - good file 2
 - good file X

This isn't, I don't think, a standard svn ignore question.

I have a repository with a huge directory in it that I don't want. Because others using the repository do, I can't just delete it from the tree. BUT, I don't want to redownload this directory every time I do a svn up. I can understand that ignore will prevent directories that I have from being uploaded to svn, but how I can I tell svn that I don't want it to redownload particular directories that are already in the repository.

What I do...

svn up
rm badDirectory

and then future svn up's redownload it. I want to prevent that.

Thanks!

edit: OK. I was hoping that SVN had a built in option that I just hadn't noticed yet. I was hoping to avoid having to "hack" around subversion's inadequacies, but the options below seem like acceptable alternatives.

edit again to address a couple of comments:

Is there particular reason why you
cannot check-out that folder and keep
it ? no disk space (probably not since
you can check-out it) ? security
reason ?

I could check out the folder. The entire svn repository is about 291 megs.. 290 of it is in this "bad" directory. Basically, some other people who have control over the repository (and therefore get to decide what goes in there) put a directory in there that really didn't need to be in there. I didn't mean for this to be a question about policy and the "proper & right" ways to use svn. I was just wondering if there was a technical solution.

Can you give a better description of
the tree structure of the repository?
Are there files at the same level as
the bad directory, or only other
directories? –

Basic structure:

repository root
 - good dir 1
    - plenty of subdirs in all of these directories
 - good dir 2
 - good dir X
 - bad dir 1
 - bad dir 2
 - bad dir X 
 - good file 1
 - good file 2
 - good file X

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

朕就是辣么酷 2024-07-20 07:13:26

我选择了与斯特凡提到的类似的稀疏结账路线。 不同的是我排除了整个目录。

这是我排除整个目录及其所有子目录所做的操作。 注意:不需要的目录已经在我的磁盘上,所以我先将其删除。

<代码>
$ rm -rf 不需要的目录
$ svn checkout url/to/repo/unwanted-directory 不需要的目录 --深度为空
$ cd root/of/my/tree
$ svn update <- 未从存储库获取不需要的目录

作为参考,我们的树中有一个“原型”目录,其中包含一堆实验代码。 因为我不在这个领域工作,所以我对在我的多个开发树中使用 1G 源没有兴趣。

I went with the sparse checkout route similar to what Stefan mentioned. The difference is I excluded a whole directory.

Here's what I did to exclude a whole directory and all its subdirectories. Note: the unwanted directory was already on my disk so I deleted it first.


$ rm -rf unwanted-directory
$ svn checkout url/to/repo/unwanted-directory unwanted-directory --depth empty
$ cd root/of/my/tree
$ svn update
<- unwanted-directory is not acquired from the repository

For reference, we have a 'prototype' directory in our tree with a bunch of experimental code. Since I don't work in this area, I have no interest in having the 1G to sources in my multiple development trees.

浅浅 2024-07-20 07:13:26

您可以执行稀疏结帐

svn co url/to/repo mywc --depth=files

这将得到你的厕所里只有文件,没有子文件夹。
您现在可以获得您想要的所有文件夹

svn up url/to/repo/subfolder1 --set-depth infinity 
svn up url/to/repo/subfolder2 --set-depth infinity 
svn up url/to/repo/subfolder3 --set-depth infinity 
...

You can do a sparse checkout:

svn co url/to/repo mywc --depth=files

that will get you a wc with only the files in it, no subfolders.
You can now get all the folders you want with

svn up url/to/repo/subfolder1 --set-depth infinity 
svn up url/to/repo/subfolder2 --set-depth infinity 
svn up url/to/repo/subfolder3 --set-depth infinity 
...
弃爱 2024-07-20 07:13:26

您可以使用脚本来 svn update --non-recursive 当前目录,然后单独递归地更新其余子目录。 使用 bash 脚本,您可以循环遍历所有子目录并跳过有问题的子目录。

像这样的事情:

#!/bin/bash

BADDIR="bad"
FILELIST="*"

svn update --non-recursive

for file in $FILELIST
do
if [ -d $file ]
then
   if [ $file != $BADDIR ] 
   then
     svn update $file
   fi
fi
done

You could use a script to svn update --non-recursive the current directory, then individually update the remaining subdirectories recurvively. With a bash script you could loop over all the subdirectories and just skip over the offending one.

Something like this:

#!/bin/bash

BADDIR="bad"
FILELIST="*"

svn update --non-recursive

for file in $FILELIST
do
if [ -d $file ]
then
   if [ $file != $BADDIR ] 
   then
     svn update $file
   fi
fi
done
幽梦紫曦~ 2024-07-20 07:13:26

如果您重命名坏文件夹中的 .svn 目录,然后运行更新,svn 将跳过该目录并说它已被删除,即使它仍然存在。

当您想要提交时,您需要将其放回原处,至少在包含错误目录的上层。

If you rename the .svn directory in the bad folder and then run an update, svn will skip over the directory and say it was deleted even though it's still there.

You will need to put it back though when you want to commit, at least at an upper level which contains the bad directory.

挽清梦 2024-07-20 07:13:26

更新除某些坏目录之外的所有当前位置数据:

svn up `svn ls | grep -v badDirectory`

Update all current location data except some bad directory :

svn up `svn ls | grep -v badDirectory`
想你只要分分秒秒 2024-07-20 07:13:26

您可以指定 --non-recursive 或 -N 来禁止它获取所有子目录

,并显式地对您想要的子目录进行更新。

一个小批处理文件可以轻松重复

\0

You could specify --non-recursive or -N to suppress it from getting all the subdirs

and the explicitly do an update on the ones that you want.

A small batch file would make it easily repeatble

\0

小瓶盖 2024-07-20 07:13:26

已经提供的解决方案,我想说,需要定期忽略存储库的一部分是存储库结构不良的明显标志。 尝试找到一种方法将其移动到存储库内的不同位置或类似的位置。

Solutions already provided, I'd say that the need to ignore one part of the repository on a regular basis is a clear sign of bad repository structure. Try to find a way to move it to a different location inside repository or something like that.

寻找我们的幸福 2024-07-20 07:13:26

Kirby 的解决方案很干净,只是它不更新当前目录。

如果您有这样的结构:

root -
     |-subdir1
     |-subdir2
     |-fileA
     |-fileB

Kirby 的解决方案将不会更新 fileA、fileB 以及后来添加到根目录的任何其他文件。

您需要添加“svn up -N”。 您可以使用别名和分号来执行此操作:(

alias myup='ls | args svn up; svn up -N'

这是 bash 别名语法。如果您使用不同的 shell,请根据需要进行更改)

Kirby's solution is clean except that it doesn't update the current directory.

If you have a structure like this:

root -
     |-subdir1
     |-subdir2
     |-fileA
     |-fileB

Kirby's solution won't update fileA, fileB and any other files that are later added to the root dir.

You'll want to add a "svn up -N". You could do this with an alias and a semicolon:

alias myup='ls | args svn up; svn up -N'

(That's bash alias syntax. If you're using a different shell, alter as needed)

撩动你心 2024-07-20 07:13:26

使用以下命令

find -maxdepth 1 ! -name . ! -name .svn ! -name badDirectory -exec svn up {} \;

在 -exec 之前继续附加所有目录,如 ! -name 目录名

find -maxdepth 1 ! -name . ! -name .svn ! -name badDirectory ! -name badDirectory2 ! -name badDirectory3 -exec svn up {} \;

Use the following command

find -maxdepth 1 ! -name . ! -name .svn ! -name badDirectory -exec svn up {} \;

Keep appending all the directories before -exec like ! -name directoryname

find -maxdepth 1 ! -name . ! -name .svn ! -name badDirectory ! -name badDirectory2 ! -name badDirectory3 -exec svn up {} \;
平生欢 2024-07-20 07:13:26

在考虑特定于供应商的解决方案时,在 TortoiseSVN 中,您可以按照 手册页,位于“签出深度”部分内的列表之后。

如果您检出稀疏工作副本(即,通过选择除完全递归以外的检出深度),您可以稍后使用存储库浏览器(称为“存储库浏览器”的部分)获取其他子文件夹或检查修改对话框(名为“本地和远程状态”的部分)。

在 Windows 资源管理器中,右键单击签出的文件夹,然后使用 TortoiseSVN → Repo-Browser 打开存储库浏览器。 找到您想要添加到工作副本中的子文件夹,然后使用上下文菜单 → 将项目更新为修订版本...

但是:我想补充一点,我会更改最终版本步。 不要在工作副本中查找要添加(或删除)的子文件夹,而是右键单击根文件夹,选择“将项目更新为修订版...”,在工作深度上单击“选择项目”按钮并在打开的文件管理器中选择所有子项。

Whilst considering vendor-specific solution, in TortoiseSVN you can achieve it by following the procedures described on the manual page, after the listing inside the section "Checkout Depth".

If you check out a sparse working copy (i.e., by choosing something other than fully recursive for the checkout depth), you can fetch additional sub-folders later by using the repository browser (the section called “The Repository Browser”) or the check for modifications dialog (the section called “Local and Remote Status”).

In windows explorer, Right click on the checked out folder, then use TortoiseSVN → Repo-Browser to bring up the repository browser. Find the sub-folder you would like to add to your working copy, then use Context Menu → Update item to revision....

BUT: I'd like to add that I'd change the final step. Instead of finding the sub-folder you'd like to add (or remove) from the working copy, right click on the root folder, choose "Update item to revision...", on Working Depth click on button "Choose Items" and select all the childs on the file manager that opens.

一念一轮回 2024-07-20 07:13:26

我发现这个问题已经被问了很长时间了,但是如果您仍然感兴趣,我偶然发现了一个不错的博客,它解释了使用“svn:ignore”的不同方法,

这是链接:http://superchlorine.com/2013/08/getting-svn-to-ignore-files- and-directories/

正如博客中所解释的,您可能可以在文件中创建“坏文件夹”列表并使用“svn propset svn:ignore -RF bad_folder_list_file”

希望有帮助!

I see the question was asked quite some time back, but if you are still interested, I stumbled upon a nice blog that explains different ways of using "svn:ignore"

Here is the link : http://superchlorine.com/2013/08/getting-svn-to-ignore-files-and-directories/

As explained in the blog, you could probably create a list of "bad folders" in a file and use "svn propset svn:ignore -R-F bad_folder_list_file"

Hope that helps !

梦屿孤独相伴 2024-07-20 07:13:26

如果它不是您(或您的团队)日常工作所必需的文件夹,您可以要求管理员更新 svn 层次结构,将该文件夹移动到与您必须更新的文件夹相同的级别(或更高级别)。

例如

projet - non-essential folder 
       \ essential folder

,您只需更新(签出)“基本文件夹”,其他文件夹也将更新
必须更新(签出)“非必要文件夹”。

If it's not a necessary folder for day to day work for you (or your group) you could ask the administrator to update the svn hierarchy to move that folder at the same level (or higher) than the folders you have to update.

for example

projet - non-essential folder 
       \ essential folder

and you will only have to update (check-out) the "essential folder" and the others will also
have to update (check-out) the "non-essential folder".

蝶…霜飞 2024-07-20 07:13:26

所以我只是想出了我认为对这个问题最快的答案。 由于 SVN 没有办法自动忽略我不想更新的目录...

这是我现有的目录结构:

root
-> 好目录 1
-> 好目录2
等等

我已经从结账中删除了坏目录。 我无法从根目录执行“svn up”,因为它会尝试重新检查坏目录。

但是,以下命令效果很好:

  ls | xargs svn up

简短、甜蜜、简单且易于记住。

So I just came up with what I think is about the fastest answer to the question. Since SVN doesn't have a way to autoignore directories that I don't want updated...

Here's my existing dir structure:

root
-> goodDir 1
-> goodDir 2
etc

I've deleted the bad directories from my checkout. I can't do an 'svn up' from the root directory, because it tries to recheck out the bad directories.

But, the following command works nicely:

  ls | xargs svn up

Short, sweet, simple, and easy to remember.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文