简体   繁体   English

如何svn忽略已添加到存储库的文件?

[英]How to svn ignore a file already added to the repository?

how can I ignore a file already added to a svn repository? 如何忽略已添加到svn存储库的文件?

I like to exclude the file config.php: 我想排除文件config.php:

$ svn st
M      .
M       config.php
M       adminfunctions.php

So, I use: 所以,我使用:

$ svn propedit svn:ignore .

And added config.php to the list. 并将config.php添加到列表中。

Then, if I do another svn st, I get the same of the first time: 然后,如果我做另一个svn st,我第一次得到相同的结果:

$ svn st
    M      .
    M       config.php
    M       adminfunctions.php

Wouldn´t the config.php be excluded just now? 请问config.php不会被排除在外吗?

Thanks in advance! 提前致谢!

svn:ignore only affects files that have not been added yet. svn:ignore仅影响尚未添加的文件。

So in your case you have to delete the files from repository with svn del — don't forget to copy them temporarily to another location). 因此,在您的情况下,您必须使用svn del从存储库中删除文件 - 不要忘记将它们临时复制到另一个位置)。 After you copy the files back into the original directory svn will not mark them as new (and try to add them). 将文件复制回原始目录后,svn不会将它们标记为新的(并尝试添加它们)。

EDIT: Alternatively, as commented by @Blake, you can use --keep-local option when you do a svn del instead of copying files to another location. 编辑:或者,正如@Blake评论的那样,当你执行svn del而不是将文件复制到另一个位置时,可以使用--keep-local选项。

Here's an issue I encountered and the solution hoping it would be useful to someone. 这是我遇到的问题以及希望它对某人有用的解决方案。

Let's say you have 'a,b,c' files in the directory 'D'. 假设你在'D'目录中有'a,b,c'文件。

You svn remove the 'a,b,c' files from your working copy and add the 'svn:ignore *' property/value to the 'D' directory and commit those changes as the revision 1234. After that if you put back the same 'a,b,c' files in this directory 'D' on your working copy then svn will still consider the 'a,b,c' files as unversionned. 你从你的工作副本中删除'a,b,c'文件并将'svn:ignore *'属性/值添加到'D'目录并将这些更改提交为修订版1234.之后如果你放回了在工作副本上的此目录“D”中的“a,b,c”文件相同,然后svn仍将“a,b,c”文件视为未版本。

To fix this: 解决这个问题:

  • Keep a backup of your 'a,b,c' files somewhere and delete those in the 'D' directory of your working copy. 在某处保留“a,b,c”文件的备份,并删除工作副本的“D”目录中的文件。
  • Update to the revision just before the 1234 one on your directory 'D'. 更新到目录“D”上1234之前的版本。 That will pull back 'a,b,c' files from the repository to your working copy. 这会将“a,b,c”文件从存储库中拉回到工作副本中。
  • Then update to HEAD revision on your directory 'D'. 然后更新目录“D”上的HEAD修订版。
  • That will remove 'a,b,c' from the directory 'D' on your working copy. 这将从工作副本上的目录“D”中删除“a,b,c”。
  • Finally put back the 'a,b,c' files in the directory 'D' of your working copy. 最后将'a,b,c'文件放回工作副本的目录'D'中。

Now 'a,b,c' are seen as ignored by svn. 现在,'a,b,c'被svn视为忽略。

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

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