简体   繁体   English

SVN:忽略已提交的文件

[英]SVN: Ignoring an already committed file

I have a settings file that is under version control using subversion. 我有一个使用subversion进行版本控制的设置文件。 Everybody has their own copy of this file, and I need this not to be ever committed. 每个人都有自己的这个文件的副本,我需要这个不被提交。 However, like I said, there is already a copy under version control. 但是,就像我说的那样,版本控制下已有一个副本。 My question is: how do I remove this file from version control without deleting everyone's file, then add it to the ignore list so it won't be committed? 我的问题是: 如何从版本控制中删除此文件而不删除每个人的文件,然后将其添加到忽略列表中,以便它不会被提交? I'm using linux command line svn. 我正在使用linux命令行svn。

Make a clean checkout, svn delete the file and add the ignore. 做一个干净的结帐, svn delete文件并添加忽略。 Then commit this. 然后提交这个。 Everyone else will have to take care (once) that their local copy isn't deleted on the next svn update , but after that, the local file would stay undisturbed and ignored by SVN. 其他人都必须小心(一次)在下一个svn update不删除它们的本地副本,但在此之后,本地文件将保持不受干扰并被SVN忽略。

If you remove the file from version control, how does a developer new to the project (or the one who accidentally deleted his local copy) get it after initial checkout? 如果您从版本控制中删除该文件,那么项目开发人员(或意外删除其本地副本的人)如何在初始结帐后获取该文件? What if there are additions to the settings file? 如果设置文件有新增内容怎么办?

I would suggest the following: Keep a default settings file (with no passwords, hostnames, connection strings, etc.) in SVN, name it something like settings.dist , and let the code work with a copy of this, named settings . 我建议如下:在SVN中保留一个默认设置文件(没有密码,主机名,连接字符串等),将其命名为settings.dist ,并让代码使用此命名settings的副本。 Every developer has to make this copy once, and can then work with her personalized settings. 每个开发人员都必须制作一次此副本,然后才能使用她的个性化设置。 If there are additions, add them to settings.dist – everyone else will get them with a update and can merge then into her personalized copy. 如果有添加内容,请将它们添加到settings.dist - 其他人都会获得更新,然后可以合并到她的个性化副本中。

After you delete the file, your users will have to recover the file from the repository using svn export . 删除文件后,您的用户必须使用svn export从存储库中恢复该文件。

$ svn export -r x path ./

Where x is a revision where the file existed before it was deleted, path is the full path to the file, and ./ is where the file will be placed. 其中x是文件在删除之前存在的修订版本, path是文件的完整路径,而./是文件的放置位置。

See svn help export for more information. 有关更多信息,请参见svn help export

I have a similar issue. 我有一个类似的问题。 In my case it's an auto-generated user settings file (visual studio) that was accidentally checked in very early in the project. 在我的例子中,它是一个自动生成的用户设置文件(visual studio),在项目的早期意外检查过。 While just deleting it might work, it seems more correct to have it removed from the history, as it was never supposed to be in there in the first place. 虽然只是删除它可能会起作用,但从历史记录中删除它似乎更为correct ,因为它从来就不应该在那里。

I came across this, which might be a new feature since this question was originally posted 7.5 years ago: 我遇到过这个问题,这可能是一个新功能,因为这个问题最初是在7.5年前发布的:

https://stackoverflow.com/a/6025750/779130 https://stackoverflow.com/a/6025750/779130

Seems like an idea would be to: 似乎一个想法是:

1) create a dump of the project.
2) filter the dump using `svndumpfilter` to exclude the unwanted file(s).
3) load the dump as a new project.

This might be the only way to completely get rid of the file. 这可能是完全摆脱文件的唯一方法。 In most cases the "delete and ignore" approach might be good enough. 在大多数情况下,“删除和忽略”方法可能已经足够了。

simply define a file containing settings that will override the default ones. 只需定义一个包含将覆盖默认设置的设置的文件。 This file is not checked into Subversion and each developer is responsible for maintaining this file according to their environments. 此文件未检入Subversion,每个开发人员负责根据其环境维护此文件。

In an Ant-based world, you would have the files: 在基于Ant的世界中,您将拥有以下文件:

settings.properties
settings-local.properties (ignored for Subversion)

and in your build.xml file 并在您的build.xml文件中

<property file="settings-local.properties"/>
<property file="settings.properties"/>

For those who couldn't connect the dots: 对于那些无法连接点的人:

  1. modify the build.xml file like proposed 像建议的那样修改build.xml文件
  2. set the setting-local.properties as ignored 将settings-local.properties设置为忽略
  3. in an init target of your build, copy the settings.properties to settings-local.properties 在构建的init目标中,将settings.properties复制到settings-local.properties
  4. wait a couple of days until everyone had the chance to run this target 等几天,直到每个人都有机会实现这个目标
  5. delete the setting.properties from Subversion 从Subversion中删除setting.properties

Voila, every developer has its own setting-local.properties and everything was done automatically (and no developer lost his or her settings, which happens if you brutally delete the file from Suvbersion and there is no "Everyone else will have to take care...") Voila,每个开发人员都有自己的setting-local.properties,一切都是自动完成的(没有开发人员丢失他或她的设置,如果你从Suvbersion中粗暴地删除文件就会发生这种情况,并且没有“其他人都必须小心。 ..“)

[[ I'm new to subversion, so maybe this doesn't make sense. [[ 我是颠覆的新手,所以也许这没有意义。 marking this as wiki -- if you know the right answer, please APPEND in the later section ]] 将此标记为维基 - 如果您知道正确的答案,请在后面的部分中进行APPEND ]]

Couldn't you have a custom set of checkout steps so each user gets a different settings folder? 你有没有自定义的结帐步骤,所以每个用户获得一个不同的设置文件夹?

 $ svn checkout http://example.com/project project .. $ dir project original_settings\\ folder1\\ folder2\\ $ svn checkout http://example.com/project/aaron_settings project\\settings .. $ dir project original_settings\\ folder1\\ folder2\\ settings\\ 

Or for new users 或者对于新用户

 $ svn import project\\settings http://example.com/project/aaron_settings 

What I'm getting at is you want each user to have a custom view of the repository. 我得到的是您希望每个用户都拥有存储库的自定义视图。 In other version control systems, you could set up a custom listing of which projects you were using and which you weren't and which you put in odd places. 在其他版本控制系统中,您可以设置一个自定义列表,其中列出了您正在使用的项目以及您不在的项目以及您在奇数位置放置的项目。

Does this work in subversion? 这是否适用于颠覆? The above code looks really risky, but maybe i'm doing it wrong. 上面的代码看起来很冒险,但也许我做错了。

WIKI: WIKI:

(nothing yet) (还没有)

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

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