简体   繁体   English

SVN:忽略但不删除文件夹

[英]SVN: Ignore but NOT delete a folder

I have a junk folder, where my application puts temporary files. 我有一个垃圾文件夹,我的应用程序在其中放置了临时文件。 I don't want to commit them (surely), but the folder must exists or application will crash. 我不想(肯定)提交它们,但是该文件夹必须存在,否则应用程序将崩溃。

If I use standard TortoiseSVN ignore feature, it will add "svn:ignore junk_folder" property to parent folder, but it will also delete "junk_folder" which cannot happen. 如果我使用标准的TortoiseSVN忽略功能,它将在父文件夹中添加“ svn:ignore junk_folder”属性,但也会删除“ junk_folder”(无法发生)。

If I revert only delete operation (did by TortoiseSVN) but leave adding "svn:ignore" property, this solution will fail. 如果我仅还原删除操作(由TortoiseSVN执行),但不添加“ svn:ignore”属性,则此解决方案将失败。 TortoiseSVN will report files inside "junk_folder" as non-versioned, which I want to avoid. TortoiseSVN会将“ junk_folder”内的文件报告为非版本化,我想避免这种情况。

Is there any solution that would allow me to completely ignore particular folder in SVN (so no matter, what will be put in it, won't be reported as unversioned and won't be auto commited as well) without deleting it? 有没有什么解决方案可以让我完全忽略SVN中的特定文件夹(因此,无论放入哪个文件夹,都不会被报告为未版本化,也不会被自动提交)而没有删除它?

EDIT : I forgot to add that I'm talking about already versioned folder. 编辑我忘了补充,我正在谈论已经版本化的文件夹。 It seems that, if you ignore (svn:ignore or proper option in TortoiseSVN) a folder that wasn't yet versioned (before first commit) then everything is OK. 看来,如果您忽略(svn:ignore或TortoiseSVN中的适当选项)一个尚未版本化的文件夹(在首次提交之前),则一切正常。 But, if you do this on the folder that already was in repository, TortoiseSVN marks it as deleted and deletes it from both repository (but not from Local Working Copy) upon next commit. 但是,如果在存储库中已经存在的文件夹上执行此操作,TortoiseSVN会将其标记为已删除,并在下次提交时从两个存储库(而不是从本地工作副本)中将其删除。

I believe you can just add an svn:ignore for "*" within that folder, instead of on "junk_folder" itself (in other words, ignore "junk_folder/*"). 我相信您可以在该文件夹中为“ *”添加一个svn:ignore,而不是在“ junk_folder”本身上(换句话说,忽略“ junk_folder / *”)。

I don't know if TortoiseSVN has a button for that, but from the command line you can do it with the command: 我不知道TortoiseSVN是否具有用于此目的的按钮,但是您可以从命令行使用以下命令进行操作:

svn propset svn:ignore "*" junk_folder svn propset svn:ignore“ *” junk_folder

(at least I think that is the right syntax, off the top of my head. if someone thinks that is wrong, please correct me) (至少我认为这是正确的语法,浮现在我头上。如果有人认为这是错误的,请纠正我)

I use this for things like compiler intermediate output folders, and it has never deleted anything. 我将其用于诸如编译器中间输出文件夹之类的东西,它从未删除过任何东西。

To re-test this, I found an unversioned directory in one of my working copies. 为了对此进行重新测试,我在一个工作副本中找到了一个未版本控制的目录。 I right clicked on the directory, and navigated to the "Add to ignore list" option. 我右键单击该目录,然后导航到“添加到忽略列表”选项。 It expanded to the directory name. 它扩展为目录名称。 I selected the directory name and received a pop up message noting that it had been added to the ignore list. 我选择了目录名称,并收到一条弹出消息,指出它已添加到忽略列表中。 Checking the working copy status, the parent folder had a property only modification. 检查工作副本状态,父文件夹进行了仅属性修改。 No files were marked for deletion. 没有文件标记为删除。

Ignoring Files And Directories 忽略文件和目录

在此处输入图片说明

As a side note , you can also hide unversioned files when using "Check for Modifications" and Commit dialogs with a checkbox near the bottom of the dialog. 附带说明 ,当使用“检查修改”和“提交”对话框时,您也可以隐藏未版本控制的文件,并在对话框底部附近有一个复选框。

I am using Eclipse Subversive and Tortoise SVN. 我正在使用Eclipse Subversive和Tortoise SVN。

My approach to this problem is to use the properties dialog from Tortoise (but I think Eclipse has the same feature) 解决这个问题的方法是使用Tortoise的属性对话框(但我认为Eclipse具有相同的功能)

If you right click on a folder in your working copy, eg 'tmp' or 'cache' etc you can simply add the 'svn:ignore' property and put a wild card in there. 如果右键单击工作副本中的文件夹,例如“ tmp”或“ cache”等,则只需添加“ svn:ignore”属性,然后在其中放置通配符即可。 You need to use the advanced button to add it because its not the the quick list of properties to add. 您需要使用高级按钮添加它,因为它不是要添加的属性的快速列表。

I am developing websites mostly on Joomla, and regularly installers or other components leave files in places that I don't want in the repo. 我主要在Joomla上开发网站,并且定期安装程序或其他组件将文件放置在我不想在回购中的位置。 And as mentioned 'svn:ignore'ing these folders using the 'right click ignore' method means these folder are completely excluded from the repo which is not what you want - you want the contents of those folders excluded, or sometimes just files with a certain extension. 正如提到的“ svn:ignore”,使用“右键单击忽略”方法意味着将这些文件夹完全从存储库中删除,这不是您想要的-您希望排除这些文件夹的内容,或者有时只删除带有一定的扩展。

after getting much advice from stackoverflow I signed up today to just to answer this question so hope it helps someone - I tried to attach screen shot but not enough rep :( 在从stackoverflow获得很多建议后,我今天注册了该网站,只是为了回答这个问题,希望对某人有帮助-我尝试附加屏幕截图,但代表数量不足:(

What do you mean " If I use standard TortoiseSVN ignore feature, it will add svn:ignore junk_folder property to parent folder, but it will also delete junk_folder ... "? 您是什么意思?“ 如果我使用标准的TortoiseSVN忽略功能,它将在父文件夹中添加svn:ignore junk_folder属性,但也会删除junk_folder ... ”?

Subversion does not delete a folder you ask it to ignore. Subversion不会删除您要求其忽略的文件夹。 In fact, that's the whole purpose of svn:ignore : To allow you to have a folder that's not in the repository without Subversion whining about it. 实际上,这就是svn:ignore的全部目的:允许您拥有一个不在Subversion中的文件夹,而无需Subversion抱怨。

How is this junk_folder created? 这个junk_folder是如何创建的? Is it by a script you use, or do you do it manually? 是使用您使用的脚本,还是手动进行? Exactly when does it get deleted? 究竟何时删除? Do you mean when you do a new checkout, junk_folder isn't there, or that TortoiseSVN deletes it as soon as you add the svn:ignore property on its parent directory? 您的意思是说,当您进行新签出时,不存在junk_folder ,或者一旦在其父目录上添加svn:ignore属性,TortoiseSVN就会将其删除?

If you need that folder permanently in your repository, but it must remain empty, you can add junk_folder to the repository, and then create a svn:ignore property that's set to * . 如果您在存储库中永久需要该文件夹,但是必须保留为空,则可以将junk_folder添加到存储库,然后创建一个设置为*svn:ignore属性。 That will ignore anything in the folder. 这将忽略文件夹中的任何内容。

My suggestion is to make sure that whatever scripts need junk_folder create it if it doesn't exist, and not to add it to your repository. 我的建议是确保不需要junk_folder任何脚本创建它(如果它不存在),并且不要将其添加到您的存储库中。 You can use this pre-commit hook to keep it out of your repository. 您可以使用此预提交挂钩将其保留在存储库之外。 That would be the best way to handle this. 那将是处理此问题的最佳方法。 There's no reason why an empty directory named junk_folder should be in your repository. 没有理由为什么您的存储库中应该有一个名为junk_folder的空目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM